1#ifndef NK_SINGLE_HEADER
2#define NK_SINGLE_HEADER
16#define NK_UNDEFINED (-1.0f)
17#define NK_UTF_INVALID 0xFFFD
20 #define NK_INPUT_MAX 16
22#ifndef NK_MAX_NUMBER_BUFFER
23 #define NK_MAX_NUMBER_BUFFER 64
25#ifndef NK_SCROLLBAR_HIDING_TIMEOUT
26 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
37 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
38 #define NK_API static inline
39 #elif defined(__cplusplus)
40 #define NK_API static inline
56#define NK_INTERN static
57#define NK_STORAGE static
58#define NK_GLOBAL static
60#define NK_FLAG(x) (1 << (x))
61#define NK_STRINGIFY(x) #x
62#define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
63#define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
64#define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
65#define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
68 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
70 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
73#ifndef NK_STATIC_ASSERT
74 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
79 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
81 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
85#define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
86#define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
87#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
89#ifdef NK_INCLUDE_STANDARD_VARARGS
90 #if defined(_MSC_VER) && (_MSC_VER >= 1600)
92 #define NK_PRINTF_FORMAT_STRING _Printf_format_string_
94 #define NK_PRINTF_FORMAT_STRING
97 #define NK_PRINTF_VARARG_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, fmtargnumber+1)))
98 #define NK_PRINTF_VALIST_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, 0)))
100 #define NK_PRINTF_VARARG_FUNC(fmtargnumber)
101 #define NK_PRINTF_VALIST_FUNC(fmtargnumber)
112#ifdef NK_INCLUDE_FIXED_TYPES
114 #define NK_INT8 int8_t
115 #define NK_UINT8 uint8_t
116 #define NK_INT16 int16_t
117 #define NK_UINT16 uint16_t
118 #define NK_INT32 int32_t
119 #define NK_UINT32 uint32_t
120 #define NK_SIZE_TYPE uintptr_t
121 #define NK_POINTER_TYPE uintptr_t
124 #define NK_INT8 signed char
127 #define NK_UINT8 unsigned char
130 #define NK_INT16 signed short
133 #define NK_UINT16 unsigned short
136 #if defined(_MSC_VER)
137 #define NK_INT32 __int32
139 #define NK_INT32 signed int
143 #if defined(_MSC_VER)
144 #define NK_UINT32 unsigned __int32
146 #define NK_UINT32 unsigned int
150 #if defined(_WIN64) && defined(_MSC_VER)
151 #define NK_SIZE_TYPE unsigned __int64
152 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
153 #define NK_SIZE_TYPE unsigned __int32
154 #elif defined(__GNUC__) || defined(__clang__)
155 #if defined(__x86_64__) || defined(__ppc64__)
156 #define NK_SIZE_TYPE unsigned long
158 #define NK_SIZE_TYPE unsigned int
161 #define NK_SIZE_TYPE unsigned long
164 #ifndef NK_POINTER_TYPE
165 #if defined(_WIN64) && defined(_MSC_VER)
166 #define NK_POINTER_TYPE unsigned __int64
167 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
168 #define NK_POINTER_TYPE unsigned __int32
169 #elif defined(__GNUC__) || defined(__clang__)
170 #if defined(__x86_64__) || defined(__ppc64__)
171 #define NK_POINTER_TYPE unsigned long
173 #define NK_POINTER_TYPE unsigned int
176 #define NK_POINTER_TYPE unsigned long
216struct nk_draw_command;
224struct nk_draw_vertex_layout_element;
228struct nk_style_slide;
330#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
437#ifdef NK_INCLUDE_COMMAND_USERDATA
993#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
994#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1070NK_API const struct nk_draw_command* nk__draw_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_context*);
1084#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
2639#define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2656#define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
2699#define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2719#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
2797#define nk_tree_element_push(ctx, type, title, state, sel) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2798#define nk_tree_element_push_id(ctx, type, title, state, sel, id) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
2878#ifdef NK_INCLUDE_STANDARD_VARARGS
2879NK_API void nk_labelf(
struct nk_context*,
nk_flags, NK_PRINTF_FORMAT_STRING
const char*, ...) NK_PRINTF_VARARG_FUNC(3);
2881NK_API void nk_labelf_wrap(struct
nk_context*, NK_PRINTF_FORMAT_STRING const
char*,...) NK_PRINTF_VARARG_FUNC(2);
2882NK_API void nk_labelf_colored_wrap(struct
nk_context*, struct
nk_color, NK_PRINTF_FORMAT_STRING const
char*,...) NK_PRINTF_VARARG_FUNC(3);
2883NK_API void nk_labelfv(struct
nk_context*,
nk_flags, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(3);
2885NK_API void nk_labelfv_wrap(struct
nk_context*, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(2);
2886NK_API void nk_labelfv_colored_wrap(struct
nk_context*, struct
nk_color, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(3);
2889NK_API void nk_value_uint(struct
nk_context*, const
char *prefix,
unsigned int);
3310#ifdef NK_INCLUDE_STANDARD_VARARGS
3311NK_API void nk_tooltipf(
struct nk_context*, NK_PRINTF_FORMAT_STRING
const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3312NK_API void nk_tooltipfv(struct
nk_context*, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3678struct nk_user_font_glyph;
3681 struct nk_user_font_glyph *glyph,
3684#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
3685struct nk_user_font_glyph {
3690 float width, height;
3704#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
3712#ifdef NK_INCLUDE_FONT_BAKING
3713enum nk_font_coord_type {
3719struct nk_baked_font {
3722 float ascent, descent;
3732struct nk_font_config {
3733 struct nk_font_config *next;
3742 unsigned char ttf_data_owned_by_atlas;
3744 unsigned char merge_mode;
3746 unsigned char pixel_snap;
3748 unsigned char oversample_v, oversample_h;
3750 unsigned char padding[3];
3754 enum nk_font_coord_type coord_type;
3760 struct nk_baked_font *font;
3764 struct nk_font_config *n;
3765 struct nk_font_config *p;
3768struct nk_font_glyph {
3771 float x0, y0, x1, y1, w, h;
3772 float u0, v0, u1, v1;
3776 struct nk_font *next;
3778 struct nk_baked_font info;
3780 struct nk_font_glyph *glyphs;
3781 const struct nk_font_glyph *fallback;
3784 struct nk_font_config *config;
3787enum nk_font_atlas_format {
3788 NK_FONT_ATLAS_ALPHA8,
3789 NK_FONT_ATLAS_RGBA32
3792struct nk_font_atlas {
3804 struct nk_font_glyph *glyphs;
3805 struct nk_font *default_font;
3806 struct nk_font *fonts;
3807 struct nk_font_config *config;
3817#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
3818NK_API void nk_font_atlas_init_default(
struct nk_font_atlas*);
3822NK_API void nk_font_atlas_begin(
struct nk_font_atlas*);
3823NK_API struct nk_font_config nk_font_config(float pixel_height);
3824NK_API struct nk_font *nk_font_atlas_add(
struct nk_font_atlas*,
const struct nk_font_config*);
3825#ifdef NK_INCLUDE_DEFAULT_FONT
3826NK_API struct nk_font* nk_font_atlas_add_default(
struct nk_font_atlas*,
float height,
const struct nk_font_config*);
3828NK_API struct nk_font* nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory,
nk_size size,
float height,
const struct nk_font_config *config);
3829#ifdef NK_INCLUDE_STANDARD_IO
3830NK_API struct nk_font* nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
float height,
const struct nk_font_config*);
3832NK_API struct nk_font *nk_font_atlas_add_compressed(
struct nk_font_atlas*,
void *memory,
nk_size size,
float height,
const struct nk_font_config*);
3833NK_API struct nk_font* nk_font_atlas_add_compressed_base85(
struct nk_font_atlas*,
const char *data,
float height,
const struct nk_font_config *config);
3834NK_API const void* nk_font_atlas_bake(
struct nk_font_atlas*,
int *width,
int *height,
enum nk_font_atlas_format);
3836NK_API const struct nk_font_glyph* nk_font_find_glyph(
struct nk_font*,
nk_rune unicode);
3837NK_API void nk_font_atlas_cleanup(
struct nk_font_atlas *atlas);
3838NK_API void nk_font_atlas_clear(
struct nk_font_atlas*);
3922#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
3952#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4021#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4022#define NK_TEXTEDIT_UNDOSTATECOUNT 99
4025#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4026#define NK_TEXTEDIT_UNDOCHARCOUNT 999
4093#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4183#ifdef NK_INCLUDE_COMMAND_USERDATA
4319 unsigned short w,
unsigned short h,
nk_handle callback_data);
4355NK_API void nk_stroke_curve(
struct nk_command_buffer*,
float,
float,
float,
float,
float,
float,
float,
float,
float line_thickness,
struct nk_color);
4434#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4448#ifdef NK_UINT_DRAW_INDEX
4453enum nk_draw_list_stroke {
4460enum nk_draw_vertex_layout_attribute {
4464 NK_VERTEX_ATTRIBUTE_COUNT
4467enum nk_draw_vertex_layout_format {
4477NK_FORMAT_COLOR_BEGIN,
4478 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4479 NK_FORMAT_R16G15B16,
4480 NK_FORMAT_R32G32B32,
4484 NK_FORMAT_R16G15B16A16,
4485 NK_FORMAT_R32G32B32A32,
4486 NK_FORMAT_R32G32B32A32_FLOAT,
4487 NK_FORMAT_R32G32B32A32_DOUBLE,
4491NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4495#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4496struct nk_draw_vertex_layout_element {
4497 enum nk_draw_vertex_layout_attribute attribute;
4498 enum nk_draw_vertex_layout_format format;
4502struct nk_draw_command {
4503 unsigned int elem_count;
4509#ifdef NK_INCLUDE_COMMAND_USERDATA
4514struct nk_draw_list {
4516 struct nk_vec2 circle_vtx[12];
4523 unsigned int element_count;
4524 unsigned int vertex_count;
4525 unsigned int cmd_count;
4528 unsigned int path_count;
4529 unsigned int path_offset;
4534#ifdef NK_INCLUDE_COMMAND_USERDATA
4540NK_API void nk_draw_list_init(
struct nk_draw_list*);
4544#define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can))
4545NK_API const struct nk_draw_command* nk__draw_list_begin(
const struct nk_draw_list*,
const struct nk_buffer*);
4546NK_API const struct nk_draw_command* nk__draw_list_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_draw_list*);
4547NK_API const struct nk_draw_command* nk__draw_list_end(
const struct nk_draw_list*,
const struct nk_buffer*);
4550NK_API void nk_draw_list_path_clear(
struct nk_draw_list*);
4551NK_API void nk_draw_list_path_line_to(
struct nk_draw_list*,
struct nk_vec2 pos);
4552NK_API void nk_draw_list_path_arc_to_fast(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
int a_min,
int a_max);
4553NK_API void nk_draw_list_path_arc_to(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
float a_min,
float a_max,
unsigned int segments);
4554NK_API void nk_draw_list_path_rect_to(
struct nk_draw_list*,
struct nk_vec2 a,
struct nk_vec2 b,
float rounding);
4555NK_API void nk_draw_list_path_curve_to(
struct nk_draw_list*,
struct nk_vec2 p2,
struct nk_vec2 p3,
struct nk_vec2 p4,
unsigned int num_segments);
4556NK_API void nk_draw_list_path_fill(
struct nk_draw_list*,
struct nk_color);
4557NK_API void nk_draw_list_path_stroke(
struct nk_draw_list*,
struct nk_color,
enum nk_draw_list_stroke closed,
float thickness);
4561NK_API void nk_draw_list_stroke_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding,
float thickness);
4563NK_API void nk_draw_list_stroke_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color,
unsigned int segs,
float thickness);
4565NK_API void nk_draw_list_stroke_poly_line(
struct nk_draw_list*,
const struct nk_vec2 *pnts,
const unsigned int cnt,
struct nk_color,
enum nk_draw_list_stroke,
float thickness,
enum nk_anti_aliasing);
4568NK_API void nk_draw_list_fill_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding);
4571NK_API void nk_draw_list_fill_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color col,
unsigned int segs);
4576NK_API void nk_draw_list_add_text(
struct nk_draw_list*,
const struct nk_user_font*,
struct nk_rect,
const char *text,
int len,
float font_height,
struct nk_color);
4577#ifdef NK_INCLUDE_COMMAND_USERDATA
4578NK_API void nk_draw_list_push_userdata(
struct nk_draw_list*,
nk_handle userdata);
5028#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5029#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5031#ifndef NK_CHART_MAX_SLOT
5032#define NK_CHART_MAX_SLOT 4
5130#ifndef NK_WINDOW_MAX_NAME
5131#define NK_WINDOW_MAX_NAME 64
5243#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5244#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5247#ifndef NK_FONT_STACK_SIZE
5248#define NK_FONT_STACK_SIZE 8
5251#ifndef NK_STYLE_ITEM_STACK_SIZE
5252#define NK_STYLE_ITEM_STACK_SIZE 16
5255#ifndef NK_FLOAT_STACK_SIZE
5256#define NK_FLOAT_STACK_SIZE 32
5259#ifndef NK_VECTOR_STACK_SIZE
5260#define NK_VECTOR_STACK_SIZE 16
5263#ifndef NK_FLAGS_STACK_SIZE
5264#define NK_FLAGS_STACK_SIZE 32
5267#ifndef NK_COLOR_STACK_SIZE
5268#define NK_COLOR_STACK_SIZE 32
5271#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5272 struct nk_config_stack_##name##_element {\
5273 prefix##_##type *address;\
5274 prefix##_##type old_value;\
5276#define NK_CONFIG_STACK(type,size)\
5277 struct nk_config_stack_##type {\
5279 struct nk_config_stack_##type##_element elements[size];\
5282#define nk_float float
5312#define NK_VALUE_PAGE_CAPACITY \
5313 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5366#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5367 struct nk_draw_list draw_list;
5369#ifdef NK_INCLUDE_COMMAND_USERDATA
5396#define NK_PI 3.141592654f
5397#define NK_UTF_INVALID 0xFFFD
5398#define NK_MAX_FLOAT_PRECISION 2
5400#define NK_UNUSED(x) ((void)(x))
5401#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5402#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5403#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5404#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5405#define NK_INBOX(px, py, x, y, w, h)\
5406 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5407#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5408 (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0)))
5409#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5410 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5412#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5413#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5414#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5415#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5417#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5418#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5419#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5425#if defined(__PTRDIFF_TYPE__)
5426# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5427# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5428#elif !defined(__GNUC__)
5429# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5430# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5431#elif defined(NK_USE_FIXED_TYPES)
5432# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5433# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5435# define NK_UINT_TO_PTR(x) ((void*)(x))
5436# define NK_PTR_TO_UINT(x) ((nk_size)(x))
5439#define NK_ALIGN_PTR(x, mask)\
5440 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5441#define NK_ALIGN_PTR_BACK(x, mask)\
5442 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5444#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5445#define NK_CONTAINER_OF(ptr,type,member)\
5446 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5453template<
typename T>
struct nk_alignof;
5454template<
typename T,
int size_diff>
struct nk_helper{
enum {value = size_diff};};
5455template<
typename T>
struct nk_helper<T,0>{
enum {value = nk_alignof<T>::value};};
5456template<
typename T>
struct nk_alignof{
struct Big {T x;
char c;};
enum {
5457 diff =
sizeof(Big) -
sizeof(T), value = nk_helper<Big, diff>::value};};
5458#define NK_ALIGNOF(t) (nk_alignof<t>::value)
5459#elif defined(_MSC_VER)
5460#define NK_ALIGNOF(t) (__alignof(t))
5462#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
5468#ifdef NK_IMPLEMENTATION
5469#ifndef NK_INTERNAL_H
5470#define NK_INTERNAL_H
5472#ifndef NK_POOL_DEFAULT_CAPACITY
5473#define NK_POOL_DEFAULT_CAPACITY 16
5476#ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
5477#define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
5480#ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
5481#define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
5485#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
5488#ifdef NK_INCLUDE_STANDARD_IO
5491#ifdef NK_INCLUDE_STANDARD_VARARGS
5496#define NK_ASSERT(expr) assert(expr)
5500#define NK_MEMSET nk_memset
5503#define NK_MEMCPY nk_memcopy
5506#define NK_SQRT nk_sqrt
5509#define NK_SIN nk_sin
5512#define NK_COS nk_cos
5515#define NK_STRTOD nk_strtod
5518#define NK_DTOA nk_dtoa
5521#define NK_DEFAULT (-1)
5528 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
5529 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
5530 (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
5531 (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
5532 defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
5533 #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
5535 #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
5539#define NK_SCHAR_MIN (-127)
5540#define NK_SCHAR_MAX 127
5541#define NK_UCHAR_MIN 0
5542#define NK_UCHAR_MAX 256
5543#define NK_SSHORT_MIN (-32767)
5544#define NK_SSHORT_MAX 32767
5545#define NK_USHORT_MIN 0
5546#define NK_USHORT_MAX 65535
5547#define NK_SINT_MIN (-2147483647)
5548#define NK_SINT_MAX 2147483647
5549#define NK_UINT_MIN 0
5550#define NK_UINT_MAX 4294967295u
5565NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
5566#define NK_FLOAT_PRECISION 0.00000000000001
5576#define nk_widget_state_reset(s)\
5577 if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\
5578 (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\
5579 else (*(s)) = NK_WIDGET_STATE_INACTIVE;
5582NK_LIB float nk_inv_sqrt(
float n);
5583NK_LIB float nk_sqrt(
float x);
5584NK_LIB float nk_sin(
float x);
5585NK_LIB float nk_cos(
float x);
5589NK_LIB void nk_unify(
struct nk_rect *clip,
const struct nk_rect *a,
float x0,
float y0,
float x1,
float y1);
5590NK_LIB double nk_pow(
double x,
int n);
5591NK_LIB int nk_ifloord(
double x);
5592NK_LIB int nk_ifloorf(
float x);
5594NK_LIB int nk_log10(
double n);
5597enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
5598NK_LIB int nk_is_lower(
int c);
5599NK_LIB int nk_is_upper(
int c);
5600NK_LIB int nk_to_upper(
int c);
5601NK_LIB int nk_to_lower(
int c);
5602NK_LIB void* nk_memcopy(
void *dst,
const void *src,
nk_size n);
5605NK_LIB char *nk_itoa(
char *s,
long n);
5606NK_LIB int nk_string_float_limit(
char *
string,
int prec);
5607NK_LIB char *nk_dtoa(
char *s,
double n);
5608NK_LIB int nk_text_clamp(
const struct nk_user_font *font,
const char *text,
int text_len,
float space,
int *glyphs,
float *text_width,
nk_rune *sep_list,
int sep_count);
5609NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct
nk_user_font *font,
const char *begin,
int byte_len,
float row_height,
const char **remaining,
struct nk_vec2 *out_offset,
int *glyphs,
int op);
5610#ifdef NK_INCLUDE_STANDARD_VARARGS
5611NK_LIB int nk_strfmt(
char *buf,
int buf_size,
const char *fmt, va_list args);
5613#ifdef NK_INCLUDE_STANDARD_IO
5618#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
5648enum nk_window_insert_location {
5680NK_LIB int nk_panel_has_header(
nk_flags flags,
const char *title);
5690NK_LIB float nk_layout_row_calculate_usable_space(
const struct nk_style *style,
enum nk_panel_type type,
float total_space,
int columns);
5721NK_LIB int nk_do_button_text_symbol(
nk_flags *state,
struct nk_command_buffer *out,
struct nk_rect bounds,
enum nk_symbol_type symbol,
const char *str,
int len,
nk_flags align,
enum nk_button_behavior behavior,
const struct nk_style_button *style,
const struct nk_user_font *font,
const struct nk_input *in);
5723NK_LIB int nk_do_button_text_image(
nk_flags *state,
struct nk_command_buffer *out,
struct nk_rect bounds,
struct nk_image img,
const char* str,
int len,
nk_flags align,
enum nk_button_behavior behavior,
const struct nk_style_button *style,
const struct nk_user_font *font,
const struct nk_input *in);
5726enum nk_toggle_type {
5741NK_LIB float nk_slider_behavior(
nk_flags *state,
struct nk_rect *logical_cursor,
struct nk_rect *visual_cursor,
struct nk_input *in,
struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
float slider_step,
float slider_steps);
5746NK_LIB float nk_scrollbar_behavior(
nk_flags *state,
struct nk_input *in,
int has_scrolling,
const struct nk_rect *scroll,
const struct nk_rect *cursor,
const struct nk_rect *empty0,
const struct nk_rect *empty1,
float scroll_offset,
float target,
float scroll_step,
enum nk_orientation o);
5748NK_LIB float nk_do_scrollbarv(
nk_flags *state,
struct nk_command_buffer *out,
struct nk_rect scroll,
int has_scrolling,
float offset,
float target,
float step,
float button_pixel_inc,
const struct nk_style_scrollbar *style,
struct nk_input *in,
const struct nk_user_font *font);
5749NK_LIB float nk_do_scrollbarh(
nk_flags *state,
struct nk_command_buffer *out,
struct nk_rect scroll,
int has_scrolling,
float offset,
float target,
float step,
float button_pixel_inc,
const struct nk_style_scrollbar *style,
struct nk_input *in,
const struct nk_user_font *font);
5752NK_LIB void nk_draw_selectable(
struct nk_command_buffer *out,
nk_flags state,
const struct nk_style_selectable *style,
int active,
const struct nk_rect *bounds,
const struct nk_rect *icon,
const struct nk_image *img,
enum nk_symbol_type sym,
const char *
string,
int len,
nk_flags align,
const struct nk_user_font *font);
5754NK_LIB int nk_do_selectable_image(
nk_flags *state,
struct nk_command_buffer *out,
struct nk_rect bounds,
const char *str,
int len,
nk_flags align,
int *value,
const struct nk_image *img,
const struct nk_style_selectable *style,
const struct nk_input *in,
const struct nk_user_font *font);
5757NK_LIB void nk_edit_draw_text(
struct nk_command_buffer *out,
const struct nk_style_edit *style,
float pos_x,
float pos_y,
float x_offset,
const char *text,
int byte_len,
float row_height,
const struct nk_user_font *font,
struct nk_color background,
struct nk_color foreground,
int is_selected);
5766enum nk_property_status {
5767 NK_PROPERTY_DEFAULT,
5771enum nk_property_filter {
5775enum nk_property_kind {
5785struct nk_property_variant {
5786 enum nk_property_kind kind;
5787 union nk_property value;
5788 union nk_property min_value;
5789 union nk_property max_value;
5790 union nk_property step;
5792NK_LIB struct nk_property_variant nk_property_variant_int(int value, int min_value, int max_value, int step);
5793NK_LIB struct nk_property_variant nk_property_variant_float(float value, float min_value, float max_value, float step);
5794NK_LIB struct nk_property_variant nk_property_variant_double(double value, double min_value, double max_value, double step);
5796NK_LIB void nk_drag_behavior(
nk_flags *state,
const struct nk_input *in,
struct nk_rect drag,
struct nk_property_variant *variant,
float inc_per_pixel);
5799NK_LIB void nk_do_property(
nk_flags *ws,
struct nk_command_buffer *out,
struct nk_rect property,
const char *name,
struct nk_property_variant *variant,
float inc_per_pixel,
char *buffer,
int *len,
int *state,
int *cursor,
int *select_begin,
int *select_end,
const struct nk_style_property *style,
enum nk_property_filter filter,
struct nk_input *in,
const struct nk_user_font *font,
struct nk_text_edit *text_edit,
enum nk_button_behavior behavior);
5800NK_LIB void nk_property(
struct nk_context *ctx,
const char *name,
struct nk_property_variant *variant,
float inc_per_pixel,
const enum nk_property_filter filter);
5843 const float threehalfs = 1.5f;
5844 union {
nk_uint i;
float f;} conv = {0};
5847 conv.i = 0x5f375A84 - (conv.i >> 1);
5848 conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
5854 return x * nk_inv_sqrt(x);
5859 NK_STORAGE const float a0 = +1.91059300966915117e-31f;
5860 NK_STORAGE const float a1 = +1.00086760103908896f;
5861 NK_STORAGE const float a2 = -1.21276126894734565e-2f;
5862 NK_STORAGE const float a3 = -1.38078780785773762e-1f;
5863 NK_STORAGE const float a4 = -2.67353392911981221e-2f;
5864 NK_STORAGE const float a5 = +2.08026600266304389e-2f;
5865 NK_STORAGE const float a6 = -3.03996055049204407e-3f;
5866 NK_STORAGE const float a7 = +1.38235642404333740e-4f;
5867 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
5874 NK_STORAGE const float a0 = 9.9995999154986614e-1f;
5875 NK_STORAGE const float a1 = 1.2548995793001028e-3f;
5876 NK_STORAGE const float a2 = -5.0648546280678015e-1f;
5877 NK_STORAGE const float a3 = 1.2942246466519995e-2f;
5878 NK_STORAGE const float a4 = 2.8668384702547972e-2f;
5879 NK_STORAGE const float a5 = 7.3726485210586547e-3f;
5880 NK_STORAGE const float a6 = -3.8510875386947414e-3f;
5881 NK_STORAGE const float a7 = 4.7196604604366623e-4f;
5882 NK_STORAGE const float a8 = -1.8776444013090451e-5f;
5883 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
5898nk_pow(
double x,
int n)
5903 n = (plus) ? n : -n;
5910 return plus ? r : 1.0 / r;
5915 x = (double)((
int)x - ((x < 0.0) ? 1 : 0));
5921 x = (float)((
int)x - ((x < 0.0f) ? 1 : 0));
5929 return (x > i) ? i+1: i;
5932 float r = x - (float)t;
5933 return (r > 0.0f) ? t+1: t;
5943 neg = (n < 0) ? 1 : 0;
5944 ret = (neg) ? (
int)-n : (int)n;
5945 while ((ret / 10) > 0) {
5949 if (neg) exp = -exp;
5955 return nk_null_rect;
5978 return nk_rect(pos.x, pos.y, size.x, size.y);
5983 return nk_rect(r[0], r[1], r[2], r[3]);
5988 return nk_recti(r[0], r[1], r[2], r[3]);
5994 ret.
x = r.x; ret.y = r.y;
6001 ret.
x = r.w; ret.y = r.h;
6005nk_shrink_rect(struct
nk_rect r, float amount)
6008 r.
w =
NK_MAX(r.w, 2 * amount);
6009 r.h =
NK_MAX(r.h, 2 * amount);
6010 res.x = r.x + amount;
6011 res.y = r.y + amount;
6012 res.w = r.w - 2 * amount;
6013 res.h = r.h - 2 * amount;
6020 r.h =
NK_MAX(r.h, 2 * pad.y);
6021 r.x += pad.x; r.y += pad.y;
6030 ret.
x =
x; ret.y =
y;
6052nk_unify(
struct nk_rect *clip,
const struct nk_rect *a,
float x0,
float y0,
6067 float pad_x,
float pad_y,
enum nk_heading direction)
6069 float w_half, h_half;
6074 r.
w = r.
w - 2 * pad_x;
6075 r.
h = r.
h - 2 * pad_y;
6080 w_half = r.
w / 2.0f;
6081 h_half = r.
h / 2.0f;
6083 if (direction ==
NK_UP) {
6087 }
else if (direction ==
NK_RIGHT) {
6089 result[1] =
nk_vec2(r.
x + r.
w, r.
y + h_half);
6091 }
else if (direction ==
NK_DOWN) {
6094 result[2] =
nk_vec2(r.
x + w_half, r.
y + r.
h);
6110NK_INTERN int nk_str_match_here(
const char *regexp,
const char *text);
6111NK_INTERN int nk_str_match_star(
int c,
const char *regexp,
const char *text);
6112NK_LIB int nk_is_lower(
int c) {
return (c >=
'a' && c <=
'z') || (c >= 0xE0 && c <= 0xFF);}
6113NK_LIB int nk_is_upper(
int c){
return (c >=
'A' && c <=
'Z') || (c >= 0xC0 && c <= 0xDF);}
6114NK_LIB int nk_to_upper(
int c) {
return (c >=
'a' && c <=
'z') ? (c - (
'a' -
'A')) : c;}
6115NK_LIB int nk_to_lower(
int c) {
return (c >=
'A' && c <=
'Z') ? (c - (
'a' +
'A')) : c;}
6118nk_memcopy(
void *dst0,
const void *src0,
nk_size length)
6121 char *dst = (
char*)dst0;
6122 const char *src = (
const char*)src0;
6123 if (length == 0 || dst == src)
6127 #define nk_wsize sizeof(nk_word)
6128 #define nk_wmask (nk_wsize-1)
6129 #define NK_TLOOP(s) if (t) NK_TLOOP1(s)
6130 #define NK_TLOOP1(s) do { s; } while (--t)
6134 if ((t | (
nk_ptr)dst) & nk_wmask) {
6135 if ((t ^ (
nk_ptr)dst) & nk_wmask || length < nk_wsize)
6138 t = nk_wsize - (t & nk_wmask);
6140 NK_TLOOP1(*dst++ = *src++);
6142 t = length / nk_wsize;
6143 NK_TLOOP(*(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src;
6144 src += nk_wsize; dst += nk_wsize);
6145 t = length & nk_wmask;
6146 NK_TLOOP(*dst++ = *src++);
6151 if ((t | (
nk_ptr)dst) & nk_wmask) {
6152 if ((t ^ (
nk_ptr)dst) & nk_wmask || length <= nk_wsize)
6157 NK_TLOOP1(*--dst = *--src);
6159 t = length / nk_wsize;
6160 NK_TLOOP(src -= nk_wsize; dst -= nk_wsize;
6161 *(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src);
6162 t = length & nk_wmask;
6163 NK_TLOOP(*--dst = *--src);
6174nk_memset(
void *ptr,
int c0,
nk_size size)
6176 #define nk_word unsigned
6177 #define nk_wsize sizeof(nk_word)
6178 #define nk_wmask (nk_wsize - 1)
6185 if (
sizeof(
unsigned int) > 2)
6191 if (size < 3 * nk_wsize) {
6192 while (size--) *dst++ = (
nk_byte)c0;
6206 t = size / nk_wsize;
6208 *(nk_word*)((
void*)dst) = c;
6213 t = (size & nk_wmask);
6225nk_zero(
void *ptr,
nk_size size)
6228 NK_MEMSET(ptr, 0, size);
6235 while (str && *str++ !=
'\0') siz++;
6239nk_strtoi(
const char *str,
const char **endptr)
6242 const char *p = str;
6249 while (*p ==
' ') p++;
6254 while (*p && *p >=
'0' && *p <=
'9') {
6255 value = value * 10 + (int) (*p -
'0');
6263nk_strtod(
const char *str,
const char **endptr)
6267 const char *p = str;
6275 while (*p ==
' ') p++;
6281 while (*p && *p !=
'.' && *p !=
'e') {
6282 value = value * 10.0 + (double) (*p -
'0');
6288 for(m = 0.1; *p && *p !=
'e'; p++ ) {
6289 value = value + (double) (*p -
'0') * m;
6299 }
else if (*p ==
'+') {
6304 for (pow = 0; *p; p++)
6305 pow = pow * 10 + (
int) (*p -
'0');
6307 for (m = 1.0, i = 0; i < pow; i++)
6314 number = value * neg;
6320nk_strtof(
const char *str,
const char **endptr)
6323 double double_value;
6324 double_value = NK_STRTOD(str, endptr);
6325 float_value = (float)double_value;
6337 if (c1 <= 'Z' && c1 >=
'A') {
6341 if (c2 <= 'Z' && c2 >=
'A') {
6345 return ((d >= 0) << 1) - 1;
6362 if (c1 <= 'Z' && c1 >=
'A') {
6366 if (c2 <= 'Z' && c2 >=
'A') {
6370 return ((d >= 0) << 1) - 1;
6376nk_str_match_here(
const char *regexp,
const char *text)
6378 if (regexp[0] ==
'\0')
6380 if (regexp[1] ==
'*')
6381 return nk_str_match_star(regexp[0], regexp+2, text);
6382 if (regexp[0] ==
'$' && regexp[1] ==
'\0')
6383 return *text ==
'\0';
6384 if (*text!=
'\0' && (regexp[0]==
'.' || regexp[0]==*text))
6385 return nk_str_match_here(regexp+1, text+1);
6389nk_str_match_star(
int c,
const char *regexp,
const char *text)
6392 if (nk_str_match_here(regexp, text))
6394 }
while (*text !=
'\0' && (*text++ == c || c ==
'.'));
6406 if (regexp[0] ==
'^')
6407 return nk_str_match_here(regexp+1, text);
6409 if (nk_str_match_here(regexp, text))
6411 }
while (*text++ !=
'\0');
6416 const char *pattern,
int *out_score)
6423 #define NK_ADJACENCY_BONUS 5
6425 #define NK_SEPARATOR_BONUS 10
6427 #define NK_CAMEL_BONUS 10
6429 #define NK_LEADING_LETTER_PENALTY (-3)
6431 #define NK_MAX_LEADING_LETTER_PENALTY (-9)
6433 #define NK_UNMATCHED_LETTER_PENALTY (-1)
6437 char const * pattern_iter = pattern;
6445 char const * best_letter = 0;
6446 int best_letter_score = 0;
6451 if (!str || !str_len || !pattern)
return 0;
6452 while (str_iter < str_len)
6454 const char pattern_letter = *pattern_iter;
6455 const char str_letter = str[str_iter];
6457 int next_match = *pattern_iter !=
'\0' &&
6458 nk_to_lower(pattern_letter) == nk_to_lower(str_letter);
6459 int rematch = best_letter && nk_to_upper(*best_letter) == nk_to_upper(str_letter);
6461 int advanced = next_match && best_letter;
6462 int pattern_repeat = best_letter && *pattern_iter !=
'\0';
6463 pattern_repeat = pattern_repeat &&
6464 nk_to_lower(*best_letter) == nk_to_lower(pattern_letter);
6466 if (advanced || pattern_repeat) {
6467 score += best_letter_score;
6469 best_letter_score = 0;
6472 if (next_match || rematch)
6476 if (pattern_iter == pattern) {
6477 int count = (int)(&str[str_iter] - str);
6478 int penalty = NK_LEADING_LETTER_PENALTY * count;
6479 if (penalty < NK_MAX_LEADING_LETTER_PENALTY)
6480 penalty = NK_MAX_LEADING_LETTER_PENALTY;
6487 new_score += NK_ADJACENCY_BONUS;
6491 new_score += NK_SEPARATOR_BONUS;
6494 if (prev_lower && nk_is_upper(str_letter))
6495 new_score += NK_CAMEL_BONUS;
6502 if (new_score >= best_letter_score) {
6504 if (best_letter != 0)
6505 score += NK_UNMATCHED_LETTER_PENALTY;
6507 best_letter = &str[str_iter];
6508 best_letter_score = new_score;
6512 score += NK_UNMATCHED_LETTER_PENALTY;
6517 prev_lower = nk_is_lower(str_letter) != 0;
6518 prev_separator = str_letter ==
'_' || str_letter ==
' ';
6525 score += best_letter_score;
6528 if (*pattern_iter !=
'\0')
6541nk_string_float_limit(
char *
string,
int prec)
6551 if (dot == (prec+1)) {
6558 return (
int)(c - string);
6561nk_strrev_ascii(
char *s)
6567 for (; i < end; ++i) {
6569 s[i] = s[len - 1 - i];
6574nk_itoa(
char *s,
long n)
6587 s[i++] = (char)(
'0' + (n % 10));
6598nk_dtoa(
char *s,
double n)
6601 int digit = 0, m = 0, m1 = 0;
6609 s[0] =
'0'; s[1] =
'\0';
6618 useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
6619 if (neg) *(c++) =
'-';
6625 n = n / (double)nk_pow(10.0, m);
6634 while (n > NK_FLOAT_PRECISION || m >= 0) {
6635 double weight = nk_pow(10.0, m);
6637 double t = (double)n / weight;
6638 digit = nk_ifloord(t);
6639 n -= ((double)digit * weight);
6640 *(c++) = (
char)(
'0' + (char)digit);
6642 if (m == 0 && n > 0)
6659 *(c++) = (
char)(
'0' + (char)(m1 % 10));
6664 for (i = 0, j = m-1; i<j; i++, j--) {
6675#ifdef NK_INCLUDE_STANDARD_VARARGS
6676#ifndef NK_INCLUDE_STANDARD_IO
6678nk_vsnprintf(
char *buf,
int buf_size,
const char *fmt, va_list args)
6683 NK_ARG_TYPE_DEFAULT,
6687 NK_ARG_FLAG_LEFT = 0x01,
6688 NK_ARG_FLAG_PLUS = 0x02,
6689 NK_ARG_FLAG_SPACE = 0x04,
6690 NK_ARG_FLAG_NUM = 0x10,
6691 NK_ARG_FLAG_ZERO = 0x20
6695 enum nk_arg_type arg_type = NK_ARG_TYPE_DEFAULT;
6696 int precision = NK_DEFAULT;
6697 int width = NK_DEFAULT;
6702 const char *iter = fmt;
6705 NK_ASSERT(buf_size);
6706 if (!buf || !buf_size || !fmt)
return 0;
6707 for (iter = fmt; *iter && len < buf_size; iter++) {
6709 while (*iter && (*iter !=
'%') && (len < buf_size))
6710 buf[len++] = *iter++;
6711 if (!(*iter) || len >= buf_size)
break;
6716 if (*iter ==
'-') flag |= NK_ARG_FLAG_LEFT;
6717 else if (*iter ==
'+') flag |= NK_ARG_FLAG_PLUS;
6718 else if (*iter ==
' ') flag |= NK_ARG_FLAG_SPACE;
6719 else if (*iter ==
'#') flag |= NK_ARG_FLAG_NUM;
6720 else if (*iter ==
'0') flag |= NK_ARG_FLAG_ZERO;
6727 if (*iter >=
'1' && *iter <=
'9') {
6733 }
else if (*iter ==
'*') {
6734 width = va_arg(args,
int);
6739 precision = NK_DEFAULT;
6743 precision = va_arg(args,
int);
6756 if (*(iter+1) ==
'h') {
6757 arg_type = NK_ARG_TYPE_CHAR;
6759 }
else arg_type = NK_ARG_TYPE_SHORT;
6761 }
else if (*iter ==
'l') {
6762 arg_type = NK_ARG_TYPE_LONG;
6764 }
else arg_type = NK_ARG_TYPE_DEFAULT;
6768 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6769 NK_ASSERT(precision == NK_DEFAULT);
6770 NK_ASSERT(width == NK_DEFAULT);
6773 }
else if (*iter ==
's') {
6775 const char *str = va_arg(args,
const char*);
6776 NK_ASSERT(str != buf &&
"buffer and argument are not allowed to overlap!");
6777 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6778 NK_ASSERT(precision == NK_DEFAULT);
6779 NK_ASSERT(width == NK_DEFAULT);
6780 if (str == buf)
return -1;
6781 while (str && *str && len < buf_size)
6782 buf[len++] = *str++;
6783 }
else if (*iter ==
'n') {
6785 signed int *n = va_arg(args,
int*);
6786 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6787 NK_ASSERT(precision == NK_DEFAULT);
6788 NK_ASSERT(width == NK_DEFAULT);
6790 }
else if (*iter ==
'c' || *iter ==
'i' || *iter ==
'd') {
6793 const char *num_iter;
6794 int num_len, num_print, padding;
6795 int cur_precision =
NK_MAX(precision, 1);
6796 int cur_width =
NK_MAX(width, 0);
6799 if (arg_type == NK_ARG_TYPE_CHAR)
6800 value = (
signed char)va_arg(args,
int);
6801 else if (arg_type == NK_ARG_TYPE_SHORT)
6802 value = (
signed short)va_arg(args,
int);
6803 else if (arg_type == NK_ARG_TYPE_LONG)
6804 value = va_arg(args,
signed long);
6805 else if (*iter ==
'c')
6806 value = (
unsigned char)va_arg(args,
int);
6807 else value = va_arg(args,
signed int);
6810 nk_itoa(number_buffer, value);
6812 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
6813 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
6814 padding =
NK_MAX(padding-1, 0);
6817 if (!(flag & NK_ARG_FLAG_LEFT)) {
6818 while (padding-- > 0 && (len < buf_size)) {
6819 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
6821 else buf[len++] =
' ';
6826 if ((flag & NK_ARG_FLAG_PLUS) && value >= 0 && len < buf_size)
6828 else if ((flag & NK_ARG_FLAG_SPACE) && value >= 0 && len < buf_size)
6832 num_print =
NK_MAX(cur_precision, num_len);
6833 while (precision && (num_print > num_len) && (len < buf_size)) {
6839 num_iter = number_buffer;
6840 while (precision && *num_iter && len < buf_size)
6841 buf[len++] = *num_iter++;
6844 if (flag & NK_ARG_FLAG_LEFT) {
6845 while ((padding-- > 0) && (len < buf_size))
6848 }
else if (*iter ==
'o' || *iter ==
'x' || *iter ==
'X' || *iter ==
'u') {
6850 unsigned long value = 0;
6851 int num_len = 0, num_print, padding = 0;
6852 int cur_precision =
NK_MAX(precision, 1);
6853 int cur_width =
NK_MAX(width, 0);
6854 unsigned int base = (*iter ==
'o') ? 8: (*iter ==
'u')? 10: 16;
6857 const char *upper_output_format =
"0123456789ABCDEF";
6858 const char *lower_output_format =
"0123456789abcdef";
6859 const char *output_format = (*iter ==
'x') ?
6860 lower_output_format: upper_output_format;
6863 if (arg_type == NK_ARG_TYPE_CHAR)
6864 value = (
unsigned char)va_arg(args,
int);
6865 else if (arg_type == NK_ARG_TYPE_SHORT)
6866 value = (
unsigned short)va_arg(args,
int);
6867 else if (arg_type == NK_ARG_TYPE_LONG)
6868 value = va_arg(args,
unsigned long);
6869 else value = va_arg(args,
unsigned int);
6873 int digit = output_format[value % base];
6875 number_buffer[num_len++] = (char)digit;
6877 }
while (value > 0);
6879 num_print =
NK_MAX(cur_precision, num_len);
6880 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
6881 if (flag & NK_ARG_FLAG_NUM)
6882 padding =
NK_MAX(padding-1, 0);
6885 if (!(flag & NK_ARG_FLAG_LEFT)) {
6886 while ((padding-- > 0) && (len < buf_size)) {
6887 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
6889 else buf[len++] =
' ';
6894 if (num_print && (flag & NK_ARG_FLAG_NUM)) {
6895 if ((*iter ==
'o') && (len < buf_size)) {
6897 }
else if ((*iter ==
'x') && ((len+1) < buf_size)) {
6900 }
else if ((*iter ==
'X') && ((len+1) < buf_size)) {
6905 while (precision && (num_print > num_len) && (len < buf_size)) {
6911 while (num_len > 0) {
6912 if (precision && (len < buf_size))
6913 buf[len++] = number_buffer[num_len-1];
6918 if (flag & NK_ARG_FLAG_LEFT) {
6919 while ((padding-- > 0) && (len < buf_size))
6922 }
else if (*iter ==
'f') {
6924 const char *num_iter;
6925 int cur_precision = (precision < 0) ? 6: precision;
6926 int prefix, cur_width =
NK_MAX(width, 0);
6927 double value = va_arg(args,
double);
6928 int num_len = 0, frac_len = 0, dot = 0;
6931 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6932 NK_DTOA(number_buffer, value);
6936 num_iter = number_buffer;
6937 while (*num_iter && *num_iter !=
'.')
6940 prefix = (*num_iter ==
'.')?(
int)(num_iter - number_buffer)+1:0;
6941 padding =
NK_MAX(cur_width - (prefix +
NK_MIN(cur_precision, num_len - prefix)) , 0);
6942 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
6943 padding =
NK_MAX(padding-1, 0);
6946 if (!(flag & NK_ARG_FLAG_LEFT)) {
6947 while (padding-- > 0 && (len < buf_size)) {
6948 if (flag & NK_ARG_FLAG_ZERO)
6950 else buf[len++] =
' ';
6955 num_iter = number_buffer;
6956 if ((flag & NK_ARG_FLAG_PLUS) && (value >= 0) && (len < buf_size))
6958 else if ((flag & NK_ARG_FLAG_SPACE) && (value >= 0) && (len < buf_size))
6961 if (dot) frac_len++;
6963 buf[len++] = *num_iter;
6964 if (*num_iter ==
'.') dot = 1;
6965 if (frac_len >= cur_precision)
break;
6970 while (frac_len < cur_precision) {
6971 if (!dot && len < buf_size) {
6981 if (flag & NK_ARG_FLAG_LEFT) {
6982 while ((padding-- > 0) && (len < buf_size))
6987 NK_ASSERT(0 &&
"specifier is not supported!");
6991 buf[(len >= buf_size)?(buf_size-1):len] = 0;
6992 result = (len >= buf_size)?-1:len;
6997nk_strfmt(
char *buf,
int buf_size,
const char *fmt, va_list args)
7001 NK_ASSERT(buf_size);
7002 if (!buf || !buf_size || !fmt)
return 0;
7003#ifdef NK_INCLUDE_STANDARD_IO
7004 result = NK_VSNPRINTF(buf, (
nk_size)buf_size, fmt, args);
7005 result = (result >= buf_size) ? -1: result;
7006 buf[buf_size-1] = 0;
7008 result = nk_vsnprintf(buf, buf_size, fmt, args);
7017 #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
7024 const int bsize =
sizeof(k1);
7025 const int nblocks = len/4;
7027 const nk_uint c1 = 0xcc9e2d51;
7028 const nk_uint c2 = 0x1b873593;
7034 for (i = 0; i < nblocks; ++i, keyptr += bsize) {
7036 k1ptr[0] = keyptr[0];
7037 k1ptr[1] = keyptr[1];
7038 k1ptr[2] = keyptr[2];
7039 k1ptr[3] = keyptr[3];
7042 k1 = NK_ROTL(k1,15);
7046 h1 = NK_ROTL(h1,13);
7047 h1 = h1*5+0xe6546b64;
7051 tail = (
const nk_byte*)(data + nblocks*4);
7054 case 3: k1 ^= (
nk_uint)(tail[2] << 16);
7055 case 2: k1 ^= (
nk_uint)(tail[1] << 8u);
7056 case 1: k1 ^= tail[0];
7058 k1 = NK_ROTL(k1,15);
7077#ifdef NK_INCLUDE_STANDARD_IO
7088 if (!path || !siz || !alloc)
7091 fd = fopen(path,
"rb");
7093 fseek(fd, 0, SEEK_END);
7100 fseek(fd, 0, SEEK_SET);
7107 *siz = (
nk_size)fread(buf, 1,*siz, fd);
7113nk_text_clamp(
const struct nk_user_font *font,
const char *text,
7114 int text_len,
float space,
int *glyphs,
float *text_width,
7115 nk_rune *sep_list,
int sep_count)
7119 float last_width = 0;
7128 float sep_width = 0;
7129 sep_count =
NK_MAX(sep_count,0);
7132 while (glyph_len && (width < space) && (len < text_len)) {
7135 for (i = 0; i < sep_count; ++i) {
7136 if (unicode != sep_list[i])
continue;
7137 sep_width = last_width = width;
7142 if (i == sep_count){
7143 last_width = sep_width = width;
7147 glyph_len =
nk_utf_decode(&text[len], &unicode, text_len - len);
7150 if (len >= text_len) {
7152 *text_width = last_width;
7156 *text_width = sep_width;
7157 return (!sep_len) ? len: sep_len;
7161nk_text_calculate_text_bounds(const struct
nk_user_font *font,
7162 const char *begin,
int byte_len,
float row_height,
const char **remaining,
7163 struct nk_vec2 *out_offset,
int *glyphs,
int op)
7165 float line_height = row_height;
7167 float line_width = 0.0f;
7173 if (!begin || byte_len <= 0 || !font)
7177 if (!glyph_len)
return text_size;
7178 glyph_width = font->width(font->userdata, font->height, begin, glyph_len);
7181 while ((text_len < byte_len) && glyph_len) {
7182 if (unicode ==
'\n') {
7183 text_size.
x =
NK_MAX(text_size.
x, line_width);
7184 text_size.
y += line_height;
7187 if (op == NK_STOP_ON_NEW_LINE)
7191 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
7195 if (unicode ==
'\r') {
7198 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
7202 *glyphs = *glyphs + 1;
7203 text_len += glyph_len;
7204 line_width += (float)glyph_width;
7205 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
7206 glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
7210 if (text_size.
x < line_width)
7211 text_size.
x = line_width;
7213 *out_offset =
nk_vec2(line_width, text_size.
y + line_height);
7214 if (line_width > 0 || text_size.
y == 0.0f)
7215 text_size.
y += line_height;
7217 *remaining = begin+text_len;
7230nk_parse_hex(
const char *p,
int length)
7234 while (len < length) {
7236 if (p[len] >=
'a' && p[len] <=
'f')
7237 i += ((p[len] -
'a') + 10);
7238 else if (p[len] >=
'A' && p[len] <=
'F')
7239 i += ((p[len] -
'A') + 10);
7240 else i += (p[len] -
'0');
7259 const char *c = rgb;
7261 col.
r = (
nk_byte)nk_parse_hex(c, 2);
7262 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
7263 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
7271 const char *c = rgb;
7273 col.
r = (
nk_byte)nk_parse_hex(c, 2);
7274 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
7275 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
7276 col.a = (
nk_byte)nk_parse_hex(c+6, 2);
7282 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
7283 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
7284 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
7285 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
7286 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
7287 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
7288 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
7289 output[6] = (char)NK_TO_HEX((col.
a & 0xF0) >> 4);
7290 output[7] = (char)NK_TO_HEX((col.
a & 0x0F));
7297 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
7298 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
7299 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
7300 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
7301 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
7302 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
7303 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
7310 return nk_rgba(c[0], c[1], c[2], c[3]);
7315 return nk_rgba(c[0], c[1], c[2], c[3]);
7330 return nk_rgb(c[0], c[1], c[2]);
7335 return nk_rgb(c[0], c[1], c[2]);
7341 ret.
r = (in & 0xFF);
7342 ret.g = ((in >> 8) & 0xFF);
7343 ret.b = ((in >> 16) & 0xFF);
7344 ret.a = (
nk_byte)((in >> 24) & 0xFF);
7360 return nk_rgba_f(c[0], c[1], c[2], c[3]);
7388nk_hsv(int h, int s, int v)
7395 return nk_hsv(c[0], c[1], c[2]);
7400 return nk_hsv(c[0], c[1], c[2]);
7415 float hf = ((float)
NK_CLAMP(0, h, 255)) / 255.0f;
7416 float sf = ((float)
NK_CLAMP(0, s, 255)) / 255.0f;
7417 float vf = ((float)
NK_CLAMP(0, v, 255)) / 255.0f;
7418 float af = ((float)
NK_CLAMP(0,
a, 255)) / 255.0f;
7424 return nk_hsva(c[0], c[1], c[2], c[3]);
7429 return nk_hsva(c[0], c[1], c[2], c[3]);
7438 out.
r = v; out.
g = v; out.
b = v; out.
a =
a;
7441 h = h / (60.0f/360.0f);
7445 q = v * (1.0f - (s * f));
7446 t = v * (1.0f - s * (1.0f - f));
7449 case 0:
default: out.r = v; out.g = t; out.b = p;
break;
7450 case 1: out.r = q; out.g = v; out.b = p;
break;
7451 case 2: out.r = p; out.g = v; out.b = t;
break;
7452 case 3: out.r = p; out.g = q; out.b = v;
break;
7453 case 4: out.r = t; out.g = p; out.b = v;
break;
7454 case 5: out.r = v; out.g = p; out.b = q;
break;}
7472 return nk_hsva_f(c[0], c[1], c[2], c[3]);
7487 *
r = (float)in.
r * s;
7488 *
g = (
float)in.
g * s;
7489 *
b = (float)in.
b * s;
7490 *
a = (
float)in.
a * s;
7508 *
r = (double)in.
r * s;
7509 *
g = (
double)in.
g * s;
7510 *
b = (double)in.
b * s;
7511 *
a = (
double)in.
a * s;
7532 float *out_v,
float *out_a,
struct nk_colorf in)
7537 const float t = in.
g; in.
g = in.
b; in.
b = t;
7541 const float t = in.
r; in.
r = in.
g; in.
g = t;
7544 chroma = in.
r - ((in.
g < in.
b) ? in.
g: in.
b);
7545 *out_h =
NK_ABS(K + (in.
g - in.
b)/(6.0f * chroma + 1e-20f));
7546 *out_s = chroma / (in.
r + 1e-20f);
7558 float *out_v,
float *out_a,
struct nk_color in)
7575 *out_h = (
nk_byte)(h * 255.0f);
7576 *out_s = (
nk_byte)(s * 255.0f);
7577 *out_v = (
nk_byte)(v * 255.0f);
7649nk_utf_validate(
nk_rune *u,
int i)
7653 if (!
NK_BETWEEN(*u, nk_utfmin[i], nk_utfmax[i]) ||
7656 for (i = 1; *u > nk_utfmax[i]; ++i);
7660nk_utf_decode_byte(
char c,
int *i)
7664 for(*i = 0; *i < (int)
NK_LEN(nk_utfmask); ++(*i)) {
7665 if (((
nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*i])
7666 return (
nk_byte)(c & ~nk_utfmask[*i]);
7673 int i, j, len, type=0;
7679 if (!c || !u)
return 0;
7680 if (!clen)
return 0;
7683 udecoded = nk_utf_decode_byte(c[0], &len);
7687 for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
7688 udecoded = (udecoded << 6) | nk_utf_decode_byte(c[i], &type);
7695 nk_utf_validate(u, len);
7699nk_utf_encode_byte(
nk_rune u,
int i)
7701 return (
char)((nk_utfbyte[i]) | ((
nk_byte)u & ~nk_utfmask[i]));
7707 len = nk_utf_validate(&u, 0);
7711 for (i = len - 1; i != 0; --i) {
7712 c[i] = nk_utf_encode_byte(u, 0);
7715 c[0] = nk_utf_encode_byte(u, len);
7729 if (!str || !len)
return 0;
7734 while (glyph_len && src_len < len) {
7736 src_len = src_len + glyph_len;
7737 glyph_len =
nk_utf_decode(text + src_len, &unicode, text_len - src_len);
7742nk_utf_at(
const char *buffer,
int length,
int index,
7755 if (!buffer || !unicode || !len)
return 0;
7772 src_len = src_len + glyph_len;
7773 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7775 if (i != index)
return 0;
7776 return buffer + src_len;
7787#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
7793 return malloc(size);
7802nk_buffer_init_default(
struct nk_buffer *buffer)
7805 alloc.userdata.ptr = 0;
7806 alloc.alloc = nk_malloc;
7807 alloc.free = nk_mfree;
7818 NK_ASSERT(initial_size);
7819 if (!b || !a || !initial_size)
return;
7821 nk_zero(b,
sizeof(*b));
7825 b->
size = initial_size;
7835 if (!b || !m || !size)
return;
7837 nk_zero(b,
sizeof(*b));
7844nk_buffer_align(
void *unaligned,
7887 if (!temp)
return 0;
7891 NK_MEMCPY(temp, b->
memory.
ptr, buffer_size);
7895 if (b->
size == buffer_size) {
7903 back_size = buffer_size - b->
size;
7904 dst =
nk_ptr_add(
void, temp, capacity - back_size);
7906 NK_MEMCPY(dst, src, back_size);
7907 b->
size = capacity - back_size;
7922 if (!b || !size)
return 0;
7929 memory = nk_buffer_align(unaligned, align, &alignment, type);
7954 memory = nk_buffer_align(unaligned, align, &alignment, type);
7958 else b->
size -= (size + alignment);
7967 void *mem = nk_buffer_alloc(b, type, size, align);
7969 NK_MEMCPY(mem, memory, size);
7975 if (!buffer)
return;
7985 if (!buffer)
return;
8027 if (!s || !b)
return;
8038 if (!buffer)
return 0;
8045 if (!buffer)
return 0;
8052 if (!buffer)
return 0;
8064#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
8066nk_str_init_default(
struct nk_str *str)
8069 alloc.userdata.ptr = 0;
8070 alloc.alloc = nk_malloc;
8071 alloc.free = nk_mfree;
8095 if (!s || !str || !len)
return 0;
8098 NK_MEMCPY(mem, str, (
nk_size)len *
sizeof(
char));
8113 if (!str || !text || !len)
return 0;
8114 for (i = 0; i < len; ++i)
8127 if (!str || !text)
return 0;
8129 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
8130 while (unicode !=
'\0' && glyph_len) {
8132 byte_len += glyph_len;
8146 if (!str || !text || !len)
return 0;
8147 for (i = 0; i < len; ++i) {
8149 if (!byte_len)
break;
8161 if (!str || !runes)
return 0;
8162 while (runes[i] !=
'\0') {
8180 NK_ASSERT(len >= 0);
8194 NK_ASSERT(((
int)pos + (
int)len + ((
int)copylen - 1)) >= 0);
8195 NK_ASSERT(((
int)pos + ((
int)copylen - 1)) >= 0);
8198 for (i = 0; i < copylen; ++i) *dst-- = *src--;
8200 NK_MEMCPY(mem, str, (
nk_size)len *
sizeof(
char));
8215 if (!str || !cstr || !len)
return 0;
8220 if (!begin)
return 0;
8242 if (!str || !text || !len)
return 0;
8243 for (i = 0; i < len; ++i)
8256 if (!str || !text)
return 0;
8258 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
8259 while (unicode !=
'\0' && glyph_len) {
8261 byte_len += glyph_len;
8275 if (!str || !runes || !len)
return 0;
8276 for (i = 0; i < len; ++i) {
8278 if (!byte_len)
break;
8290 if (!str || !runes)
return 0;
8291 while (runes[i] !=
'\0') {
8302 NK_ASSERT(len >= 0);
8317 NK_ASSERT(len >= 0);
8318 if (!str || len < 0)
return;
8319 if (len >= str->
len) {
8324 index = str->
len - len;
8356 NK_ASSERT(s->
len >= pos + len);
8357 if (s->
len < pos + len)
8390 if (!str || !unicode || !len)
return 0;
8407 src_len = src_len + glyph_len;
8408 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
8410 if (i != pos)
return 0;
8411 return text + src_len;
8433 if (!str || !unicode || !len)
return 0;
8450 src_len = src_len + glyph_len;
8451 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
8453 if (i != pos)
return 0;
8454 return text + src_len;
8521 if (!cb || !b)
return;
8536 b->
clip = nk_null_rect;
8537#ifdef NK_INCLUDE_COMMAND_USERDATA
8559 unaligned = (
nk_byte*)cmd + size;
8562#ifdef NK_ZERO_COMMAND_MEMORY
8563 NK_MEMSET(cmd, 0, size + alignment);
8568#ifdef NK_INCLUDE_COMMAND_USERDATA
8589 cmd->
x = (short)r.
x;
8590 cmd->
y = (
short)r.
y;
8591 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
8592 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
8596 float x1,
float y1,
float line_thickness,
struct nk_color c)
8605 cmd->
begin.
x = (short)x0;
8606 cmd->
begin.
y = (short)y0;
8607 cmd->
end.
x = (short)x1;
8608 cmd->
end.
y = (short)y1;
8613 float ctrl0x,
float ctrl0y,
float ctrl1x,
float ctrl1y,
8624 cmd->
begin.
x = (short)ax;
8625 cmd->
begin.
y = (short)ay;
8626 cmd->
ctrl[0].
x = (short)ctrl0x;
8627 cmd->
ctrl[0].
y = (short)ctrl0y;
8628 cmd->
ctrl[1].
x = (short)ctrl1x;
8629 cmd->
ctrl[1].
y = (short)ctrl1y;
8630 cmd->
end.
x = (short)bx;
8631 cmd->
end.
y = (short)by;
8640 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0 ||
line_thickness <= 0)
return;
8644 clip->
x, clip->
y, clip->
w, clip->
h))
return;
8651 cmd->
x = (short)rect.
x;
8652 cmd->
y = (
short)rect.
y;
8653 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
8654 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
8663 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
8667 clip->
x, clip->
y, clip->
w, clip->
h))
return;
8674 cmd->
x = (short)rect.
x;
8675 cmd->
y = (
short)rect.
y;
8676 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
8677 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
8687 if (!b || rect.
w == 0 || rect.
h == 0)
return;
8691 clip->
x, clip->
y, clip->
w, clip->
h))
return;
8697 cmd->
x = (short)rect.
x;
8698 cmd->
y = (
short)rect.
y;
8699 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
8700 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
8708 float line_thickness,
struct nk_color c)
8722 cmd->
x = (short)r.
x;
8723 cmd->
y = (
short)r.
y;
8724 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
8725 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
8733 if (!b || c.
a == 0 || r.
w == 0 || r.
h == 0)
return;
8743 cmd->
x = (short)r.
x;
8744 cmd->
y = (
short)r.
y;
8745 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
8746 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
8751 float a_min,
float a_max,
float line_thickness,
struct nk_color c)
8759 cmd->
cx = (short)
cx;
8760 cmd->
cy = (short)
cy;
8761 cmd->
r = (
unsigned short)radius;
8768 float a_min,
float a_max,
struct nk_color c)
8772 if (!b || c.
a == 0)
return;
8776 cmd->
cx = (short)
cx;
8777 cmd->
cy = (short)
cy;
8778 cmd->
r = (
unsigned short)radius;
8785 float y1,
float x2,
float y2,
float line_thickness,
struct nk_color c)
8790 if (
b->use_clipping) {
8792 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
8793 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
8802 cmd->
a.
x = (short)x0;
8803 cmd->
a.
y = (short)y0;
8804 cmd->
b.
x = (short)x1;
8805 cmd->
b.
y = (short)y1;
8806 cmd->
c.
x = (short)x2;
8807 cmd->
c.
y = (short)y2;
8812 float y1,
float x2,
float y2,
struct nk_color c)
8816 if (!
b ||
c.a == 0)
return;
8818 if (
b->use_clipping) {
8820 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
8821 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
8829 cmd->
a.
x = (short)x0;
8830 cmd->
a.
y = (short)y0;
8831 cmd->
b.
x = (short)x1;
8832 cmd->
b.
y = (short)y1;
8833 cmd->
c.
x = (short)x2;
8834 cmd->
c.
y = (short)y2;
8839 float line_thickness,
struct nk_color col)
8867 if (!b || col.
a == 0)
return;
8881 float line_thickness,
struct nk_color col)
8916 cmd->
x = (short)r.
x;
8917 cmd->
y = (
short)r.
y;
8918 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
8919 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
8939 cmd->
x = (short)r.
x;
8940 cmd->
y = (
short)r.
y;
8941 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
8942 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
8948 const char *
string,
int length,
const struct nk_user_font *font,
8951 float text_width = 0;
8956 if (!b || !
string || !
length || (bg.
a == 0 && fg.
a == 0))
return;
8965 if (text_width > r.
w){
8967 float txt_width = (float)text_width;
8968 length = nk_text_clamp(font,
string, length, r.
w, &glyphs, &txt_width, 0,0);
8971 if (!length)
return;
8975 cmd->
x = (short)r.
x;
8976 cmd->
y = (
short)r.
y;
8977 cmd->
w = (
unsigned short)r.
w;
8978 cmd->
h = (
unsigned short)r.
h;
8996#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
8998nk_draw_list_init(
struct nk_draw_list *list)
9003 nk_zero(list,
sizeof(*list));
9004 for (i = 0; i <
NK_LEN(list->circle_vtx); ++i) {
9005 const float a = ((float)i / (
float)
NK_LEN(list->circle_vtx)) * 2 *
NK_PI;
9006 list->circle_vtx[i].x = (float)NK_COS(a);
9007 list->circle_vtx[i].y = (float)NK_SIN(a);
9011nk_draw_list_setup(
struct nk_draw_list *canvas,
const struct nk_convert_config *config,
9018 NK_ASSERT(vertices);
9019 NK_ASSERT(elements);
9020 if (!canvas || !config || !cmds || !vertices || !elements)
9023 canvas->buffer = cmds;
9024 canvas->config = *config;
9025 canvas->elements = elements;
9026 canvas->vertices = vertices;
9027 canvas->line_AA = line_aa;
9028 canvas->shape_AA = shape_aa;
9029 canvas->clip_rect = nk_null_rect;
9031 canvas->cmd_offset = 0;
9032 canvas->element_count = 0;
9033 canvas->vertex_count = 0;
9034 canvas->cmd_offset = 0;
9035 canvas->cmd_count = 0;
9036 canvas->path_count = 0;
9038NK_API const struct nk_draw_command*
9039nk__draw_list_begin(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
9043 const struct nk_draw_command *cmd;
9046 if (!buffer || !buffer->
size || !canvas->cmd_count)
9050 offset = buffer->
memory.
size - canvas->cmd_offset;
9051 cmd =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
9054NK_API const struct nk_draw_command*
9055nk__draw_list_end(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
9060 const struct nk_draw_command *end;
9064 if (!buffer || !canvas)
9069 offset = size - canvas->cmd_offset;
9070 end =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
9071 end -= (canvas->cmd_count-1);
9074NK_API const struct nk_draw_command*
9075nk__draw_list_next(
const struct nk_draw_command *cmd,
9076 const struct nk_buffer *buffer,
const struct nk_draw_list *canvas)
9078 const struct nk_draw_command *end;
9081 if (!cmd || !buffer || !canvas)
9084 end = nk__draw_list_end(canvas, buffer);
9085 if (cmd <= end)
return 0;
9089nk_draw_list_alloc_path(
struct nk_draw_list *list,
int count)
9096 point_size * (
nk_size)count, point_align);
9098 if (!points)
return 0;
9099 if (!list->path_offset) {
9101 list->path_offset = (
unsigned int)((
nk_byte*)points - (
nk_byte*)memory);
9103 list->path_count += (
unsigned int)count;
9107nk_draw_list_path_last(struct nk_draw_list *list)
9111 NK_ASSERT(list->path_count);
9114 point += (list->path_count-1);
9118nk_draw_list_push_command(
struct nk_draw_list *list,
struct nk_rect clip,
9123 struct nk_draw_command *cmd;
9126 cmd = (
struct nk_draw_command*)
9127 nk_buffer_alloc(list->buffer,
NK_BUFFER_BACK, cmd_size, cmd_align);
9130 if (!list->cmd_count) {
9137 cmd->elem_count = 0;
9138 cmd->clip_rect = clip;
9139 cmd->texture = texture;
9140#ifdef NK_INCLUDE_COMMAND_USERDATA
9141 cmd->userdata = list->userdata;
9145 list->clip_rect = clip;
9149nk_draw_list_command_last(
struct nk_draw_list *list)
9153 struct nk_draw_command *cmd;
9154 NK_ASSERT(list->cmd_count);
9158 cmd =
nk_ptr_add(
struct nk_draw_command, memory, size - list->cmd_offset);
9159 return (cmd - (list->cmd_count-1));
9162nk_draw_list_add_clip(
struct nk_draw_list *list,
struct nk_rect rect)
9166 if (!list->cmd_count) {
9167 nk_draw_list_push_command(list, rect, list->config.null.texture);
9169 struct nk_draw_command *prev = nk_draw_list_command_last(list);
9170 if (prev->elem_count == 0)
9171 prev->clip_rect = rect;
9172 nk_draw_list_push_command(list, rect, prev->texture);
9176nk_draw_list_push_image(
struct nk_draw_list *list,
nk_handle texture)
9180 if (!list->cmd_count) {
9181 nk_draw_list_push_command(list, nk_null_rect, texture);
9183 struct nk_draw_command *prev = nk_draw_list_command_last(list);
9184 if (prev->elem_count == 0) {
9185 prev->texture = texture;
9186 #ifdef NK_INCLUDE_COMMAND_USERDATA
9187 prev->userdata = list->userdata;
9189 }
else if (prev->texture.id != texture.
id
9190 #ifdef NK_INCLUDE_COMMAND_USERDATA
9191 || prev->userdata.id != list->userdata.id
9193 ) nk_draw_list_push_command(list, prev->clip_rect, texture);
9196#ifdef NK_INCLUDE_COMMAND_USERDATA
9198nk_draw_list_push_userdata(
struct nk_draw_list *list,
nk_handle userdata)
9200 list->userdata = userdata;
9204nk_draw_list_alloc_vertices(
struct nk_draw_list *list,
nk_size count)
9208 if (!list)
return 0;
9210 list->config.vertex_size*count, list->config.vertex_alignment);
9212 list->vertex_count += (
unsigned int)count;
9223 if(
sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
9224 "To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
9228nk_draw_list_alloc_elements(
struct nk_draw_list *list,
nk_size count)
9231 struct nk_draw_command *cmd;
9235 if (!list)
return 0;
9237 ids = (nk_draw_index*)
9238 nk_buffer_alloc(list->elements,
NK_BUFFER_FRONT, elem_size*count, elem_align);
9240 cmd = nk_draw_list_command_last(list);
9241 list->element_count += (
unsigned int)count;
9242 cmd->elem_count += (
unsigned int)count;
9246nk_draw_vertex_layout_element_is_end_of_layout(
9247 const struct nk_draw_vertex_layout_element *element)
9249 return (element->attribute == NK_VERTEX_ATTRIBUTE_COUNT ||
9250 element->format == NK_FORMAT_COUNT);
9253nk_draw_vertex_color(
void *attr,
const float *vals,
9254 enum nk_draw_vertex_layout_format format)
9258 NK_ASSERT(format >= NK_FORMAT_COLOR_BEGIN);
9259 NK_ASSERT(format <= NK_FORMAT_COLOR_END);
9260 if (format < NK_FORMAT_COLOR_BEGIN || format > NK_FORMAT_COLOR_END)
return;
9268 default: NK_ASSERT(0 &&
"Invalid vertex layout color format");
break;
9269 case NK_FORMAT_R8G8B8A8:
9270 case NK_FORMAT_R8G8B8: {
9272 NK_MEMCPY(attr, &col.
r,
sizeof(col));
9274 case NK_FORMAT_B8G8R8A8: {
9277 NK_MEMCPY(attr, &bgra,
sizeof(bgra));
9279 case NK_FORMAT_R16G15B16: {
9281 col[0] = (
nk_ushort)(val[0]*(
float)NK_USHORT_MAX);
9282 col[1] = (
nk_ushort)(val[1]*(
float)NK_USHORT_MAX);
9283 col[2] = (
nk_ushort)(val[2]*(
float)NK_USHORT_MAX);
9284 NK_MEMCPY(attr, col,
sizeof(col));
9286 case NK_FORMAT_R16G15B16A16: {
9288 col[0] = (
nk_ushort)(val[0]*(
float)NK_USHORT_MAX);
9289 col[1] = (
nk_ushort)(val[1]*(
float)NK_USHORT_MAX);
9290 col[2] = (
nk_ushort)(val[2]*(
float)NK_USHORT_MAX);
9291 col[3] = (
nk_ushort)(val[3]*(
float)NK_USHORT_MAX);
9292 NK_MEMCPY(attr, col,
sizeof(col));
9294 case NK_FORMAT_R32G32B32: {
9296 col[0] = (
nk_uint)(val[0]*(
float)NK_UINT_MAX);
9297 col[1] = (
nk_uint)(val[1]*(
float)NK_UINT_MAX);
9298 col[2] = (
nk_uint)(val[2]*(
float)NK_UINT_MAX);
9299 NK_MEMCPY(attr, col,
sizeof(col));
9301 case NK_FORMAT_R32G32B32A32: {
9303 col[0] = (
nk_uint)(val[0]*(
float)NK_UINT_MAX);
9304 col[1] = (
nk_uint)(val[1]*(
float)NK_UINT_MAX);
9305 col[2] = (
nk_uint)(val[2]*(
float)NK_UINT_MAX);
9306 col[3] = (
nk_uint)(val[3]*(
float)NK_UINT_MAX);
9307 NK_MEMCPY(attr, col,
sizeof(col));
9309 case NK_FORMAT_R32G32B32A32_FLOAT:
9310 NK_MEMCPY(attr, val,
sizeof(
float)*4);
9312 case NK_FORMAT_R32G32B32A32_DOUBLE: {
9314 col[0] = (double)val[0];
9315 col[1] = (double)val[1];
9316 col[2] = (double)val[2];
9317 col[3] = (double)val[3];
9318 NK_MEMCPY(attr, col,
sizeof(col));
9320 case NK_FORMAT_RGB32:
9321 case NK_FORMAT_RGBA32: {
9324 NK_MEMCPY(attr, &color,
sizeof(color));
9328nk_draw_vertex_element(
void *dst,
const float *values,
int value_count,
9329 enum nk_draw_vertex_layout_format format)
9332 void *attribute = dst;
9334 NK_ASSERT(format < NK_FORMAT_COLOR_BEGIN);
9335 if (format >= NK_FORMAT_COLOR_BEGIN && format <= NK_FORMAT_COLOR_END)
return;
9336 for (value_index = 0; value_index < value_count; ++value_index) {
9338 default: NK_ASSERT(0 &&
"invalid vertex layout format");
break;
9339 case NK_FORMAT_SCHAR: {
9340 char value = (char)
NK_CLAMP((
float)NK_SCHAR_MIN, values[value_index], (float)NK_SCHAR_MAX);
9341 NK_MEMCPY(attribute, &value,
sizeof(value));
9342 attribute = (
void*)((
char*)attribute +
sizeof(char));
9344 case NK_FORMAT_SSHORT: {
9346 NK_MEMCPY(attribute, &value,
sizeof(value));
9347 attribute = (
void*)((
char*)attribute +
sizeof(value));
9349 case NK_FORMAT_SINT: {
9351 NK_MEMCPY(attribute, &value,
sizeof(value));
9352 attribute = (
void*)((
char*)attribute +
sizeof(
nk_int));
9354 case NK_FORMAT_UCHAR: {
9355 unsigned char value = (
unsigned char)
NK_CLAMP((
float)NK_UCHAR_MIN, values[value_index], (float)NK_UCHAR_MAX);
9356 NK_MEMCPY(attribute, &value,
sizeof(value));
9357 attribute = (
void*)((
char*)attribute +
sizeof(
unsigned char));
9359 case NK_FORMAT_USHORT: {
9361 NK_MEMCPY(attribute, &value,
sizeof(value));
9362 attribute = (
void*)((
char*)attribute +
sizeof(value));
9364 case NK_FORMAT_UINT: {
9366 NK_MEMCPY(attribute, &value,
sizeof(value));
9367 attribute = (
void*)((
char*)attribute +
sizeof(
nk_uint));
9369 case NK_FORMAT_FLOAT:
9370 NK_MEMCPY(attribute, &values[value_index],
sizeof(values[value_index]));
9371 attribute = (
void*)((
char*)attribute +
sizeof(float));
9373 case NK_FORMAT_DOUBLE: {
9374 double value = (double)values[value_index];
9375 NK_MEMCPY(attribute, &value,
sizeof(value));
9376 attribute = (
void*)((
char*)attribute +
sizeof(double));
9385 void *result = (
void*)((
char*)dst + config->
vertex_size);
9386 const struct nk_draw_vertex_layout_element *elem_iter = config->
vertex_layout;
9387 while (!nk_draw_vertex_layout_element_is_end_of_layout(elem_iter)) {
9388 void *address = (
void*)((
char*)dst + elem_iter->offset);
9389 switch (elem_iter->attribute) {
9390 case NK_VERTEX_ATTRIBUTE_COUNT:
9391 default: NK_ASSERT(0 &&
"wrong element attribute");
break;
9392 case NK_VERTEX_POSITION: nk_draw_vertex_element(address, &pos.
x, 2, elem_iter->format);
break;
9393 case NK_VERTEX_TEXCOORD: nk_draw_vertex_element(address, &uv.
x, 2, elem_iter->format);
break;
9394 case NK_VERTEX_COLOR: nk_draw_vertex_color(address, &color.
r, elem_iter->format);
break;
9401nk_draw_list_stroke_poly_line(
struct nk_draw_list *list,
const struct nk_vec2 *points,
9402 const unsigned int points_count,
struct nk_color color,
enum nk_draw_list_stroke closed,
9410 if (!list || points_count < 2)
return;
9412 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
9413 count = points_count;
9414 if (!closed) count = points_count-1;
9415 thick_line = thickness > 1.0f;
9417#ifdef NK_INCLUDE_COMMAND_USERDATA
9418 nk_draw_list_push_userdata(list, list->userdata);
9421 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
9428 const float AA_SIZE = 1.0f;
9435 nk_size index = list->vertex_count;
9437 const nk_size idx_count = (thick_line) ? (count * 18) : (count * 12);
9438 const nk_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3);
9440 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9441 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9444 struct nk_vec2 *normals, *temp;
9445 if (!vtx || !ids)
return;
9450 size = pnt_size * ((thick_line) ? 5 : 3) * points_count;
9452 if (!normals)
return;
9453 temp = normals + points_count;
9456 vtx = (
void*)((
nk_byte*)list->vertices->memory.ptr + vertex_offset);
9459 for (i1 = 0; i1 < count; ++i1) {
9460 const nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
9467 len = nk_inv_sqrt(len);
9471 normals[i1].
x = diff.
y;
9472 normals[i1].
y = -diff.
x;
9476 normals[points_count-1] = normals[points_count-2];
9485 temp[(points_count-1) * 2 + 0] =
nk_vec2_add(points[points_count-1], d);
9486 temp[(points_count-1) * 2 + 1] =
nk_vec2_sub(points[points_count-1], d);
9491 for (i1 = 0; i1 < count; i1++) {
9494 nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
9495 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 3);
9499 dmr2 = dm.x * dm.x + dm.y* dm.y;
9500 if (dmr2 > 0.000001f) {
9501 float scale = 1.0f/dmr2;
9502 scale =
NK_MIN(100.0f, scale);
9510 ids[0] = (nk_draw_index)(idx2 + 0); ids[1] = (nk_draw_index)(idx1+0);
9511 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
9512 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+0);
9513 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
9514 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
9515 ids[10]= (nk_draw_index)(idx2 + 0); ids[11]= (nk_draw_index)(idx2+1);
9521 for (i = 0; i < points_count; ++i) {
9522 const struct nk_vec2 uv = list->config.null.uv;
9523 vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
9524 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
9525 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
9529 const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
9539 d1 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness + AA_SIZE);
9540 d2 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness);
9542 temp[(points_count-1)*4+0] =
nk_vec2_add(points[points_count-1], d1);
9543 temp[(points_count-1)*4+1] =
nk_vec2_add(points[points_count-1], d2);
9544 temp[(points_count-1)*4+2] =
nk_vec2_sub(points[points_count-1], d2);
9545 temp[(points_count-1)*4+3] =
nk_vec2_sub(points[points_count-1], d1);
9550 for (i1 = 0; i1 < count; ++i1) {
9552 const nk_size i2 = ((i1+1) == points_count) ? 0: (i1 + 1);
9553 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 4);
9557 float dmr2 = dm.
x * dm.
x + dm.
y* dm.
y;
9558 if (dmr2 > 0.000001f) {
9559 float scale = 1.0f/dmr2;
9560 scale =
NK_MIN(100.0f, scale);
9564 dm_out =
nk_vec2_muls(dm, ((half_inner_thickness) + AA_SIZE));
9572 ids[0] = (nk_draw_index)(idx2 + 1); ids[1] = (nk_draw_index)(idx1+1);
9573 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
9574 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+1);
9575 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
9576 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
9577 ids[10]= (nk_draw_index)(idx2 + 0); ids[11] = (nk_draw_index)(idx2+1);
9578 ids[12]= (nk_draw_index)(idx2 + 2); ids[13] = (nk_draw_index)(idx1+2);
9579 ids[14]= (nk_draw_index)(idx1 + 3); ids[15] = (nk_draw_index)(idx1+3);
9580 ids[16]= (nk_draw_index)(idx2 + 3); ids[17] = (nk_draw_index)(idx2+2);
9586 for (i = 0; i < points_count; ++i) {
9587 const struct nk_vec2 uv = list->config.null.uv;
9588 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
9589 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
9590 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
9591 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+3], uv, col_trans);
9599 nk_size idx = list->vertex_count;
9600 const nk_size idx_count = count * 6;
9601 const nk_size vtx_count = count * 4;
9602 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9603 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9604 if (!vtx || !ids)
return;
9606 for (i1 = 0; i1 < count; ++i1) {
9608 const struct nk_vec2 uv = list->config.null.uv;
9609 const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
9610 const struct nk_vec2 p1 = points[i1];
9611 const struct nk_vec2 p2 = points[i2];
9618 len = nk_inv_sqrt(len);
9623 dx = diff.
x * (thickness * 0.5f);
9624 dy = diff.
y * (thickness * 0.5f);
9626 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x + dy, p1.
y - dx), uv, col);
9627 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x + dy, p2.
y - dx), uv, col);
9628 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x - dy, p2.
y + dx), uv, col);
9629 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x - dy, p1.
y + dx), uv, col);
9631 ids[0] = (nk_draw_index)(idx+0); ids[1] = (nk_draw_index)(idx+1);
9632 ids[2] = (nk_draw_index)(idx+2); ids[3] = (nk_draw_index)(idx+0);
9633 ids[4] = (nk_draw_index)(idx+2); ids[5] = (nk_draw_index)(idx+3);
9641nk_draw_list_fill_poly_convex(
struct nk_draw_list *list,
9642 const struct nk_vec2 *points,
const unsigned int points_count,
9651 if (!list || points_count < 3)
return;
9653#ifdef NK_INCLUDE_COMMAND_USERDATA
9654 nk_draw_list_push_userdata(list, list->userdata);
9657 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
9667 const float AA_SIZE = 1.0f;
9669 nk_size index = list->vertex_count;
9671 const nk_size idx_count = (points_count-2)*3 + points_count*6;
9672 const nk_size vtx_count = (points_count*2);
9674 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9675 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9679 unsigned int vtx_inner_idx = (
unsigned int)(index + 0);
9680 unsigned int vtx_outer_idx = (
unsigned int)(index + 1);
9681 if (!vtx || !ids)
return;
9686 size = pnt_size * points_count;
9688 if (!normals)
return;
9689 vtx = (
void*)((
nk_byte*)list->vertices->memory.ptr + vertex_offset);
9692 for (i = 2; i < points_count; i++) {
9693 ids[0] = (nk_draw_index)(vtx_inner_idx);
9694 ids[1] = (nk_draw_index)(vtx_inner_idx + ((i-1) << 1));
9695 ids[2] = (nk_draw_index)(vtx_inner_idx + (i << 1));
9700 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
9701 struct nk_vec2 p0 = points[i0];
9702 struct nk_vec2 p1 = points[i1];
9708 len = nk_inv_sqrt(len);
9712 normals[i0].
x = diff.
y;
9713 normals[i0].
y = -diff.
x;
9717 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
9718 const struct nk_vec2 uv = list->config.null.uv;
9719 struct nk_vec2 n0 = normals[i0];
9720 struct nk_vec2 n1 = normals[i1];
9722 float dmr2 = dm.
x*dm.
x + dm.
y*dm.
y;
9723 if (dmr2 > 0.000001f) {
9724 float scale = 1.0f / dmr2;
9725 scale =
NK_MIN(scale, 100.0f);
9731 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_sub(points[i1], dm), uv, col);
9732 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_add(points[i1], dm), uv, col_trans);
9735 ids[0] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
9736 ids[1] = (nk_draw_index)(vtx_inner_idx+(i0<<1));
9737 ids[2] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
9738 ids[3] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
9739 ids[4] = (nk_draw_index)(vtx_outer_idx+(i1<<1));
9740 ids[5] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
9747 nk_size index = list->vertex_count;
9748 const nk_size idx_count = (points_count-2)*3;
9749 const nk_size vtx_count = points_count;
9750 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9751 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9753 if (!vtx || !ids)
return;
9754 for (i = 0; i < vtx_count; ++i)
9755 vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
9756 for (i = 2; i < points_count; ++i) {
9757 ids[0] = (nk_draw_index)index;
9758 ids[1] = (nk_draw_index)(index+ i - 1);
9759 ids[2] = (nk_draw_index)(index+i);
9765nk_draw_list_path_clear(
struct nk_draw_list *list)
9770 list->path_count = 0;
9771 list->path_offset = 0;
9774nk_draw_list_path_line_to(
struct nk_draw_list *list,
struct nk_vec2 pos)
9777 struct nk_draw_command *cmd = 0;
9780 if (!list->cmd_count)
9781 nk_draw_list_add_clip(list, nk_null_rect);
9783 cmd = nk_draw_list_command_last(list);
9784 if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
9785 nk_draw_list_push_image(list, list->config.null.texture);
9787 points = nk_draw_list_alloc_path(list, 1);
9788 if (!points)
return;
9792nk_draw_list_path_arc_to_fast(
struct nk_draw_list *list,
struct nk_vec2 center,
9793 float radius,
int a_min,
int a_max)
9798 if (a_min <= a_max) {
9799 for (a = a_min; a <= a_max; a++) {
9801 const float x = center.
x + c.
x * radius;
9802 const float y = center.
y + c.
y * radius;
9803 nk_draw_list_path_line_to(list,
nk_vec2(
x,
y));
9808nk_draw_list_path_arc_to(
struct nk_draw_list *list,
struct nk_vec2 center,
9809 float radius,
float a_min,
float a_max,
unsigned int segments)
9814 if (radius == 0.0f)
return;
9834 {
const float d_angle = (a_max - a_min) / (
float)segments;
9835 const float sin_d = (float)NK_SIN(d_angle);
9836 const float cos_d = (float)NK_COS(d_angle);
9838 float cx = (float)NK_COS(a_min) * radius;
9839 float cy = (float)NK_SIN(a_min) * radius;
9840 for(i = 0; i <= segments; ++i) {
9841 float new_cx, new_cy;
9842 const float x = center.
x + cx;
9843 const float y = center.
y + cy;
9844 nk_draw_list_path_line_to(list,
nk_vec2(
x,
y));
9846 new_cx = cx * cos_d - cy * sin_d;
9847 new_cy = cy * cos_d + cx * sin_d;
9853nk_draw_list_path_rect_to(
struct nk_draw_list *list,
struct nk_vec2 a,
9854 struct nk_vec2 b,
float rounding)
9860 r =
NK_MIN(r, ((b.
x-a.
x) < 0) ? -(b.
x-a.
x): (b.
x-a.
x));
9861 r =
NK_MIN(r, ((b.
y-a.
y) < 0) ? -(b.
y-a.
y): (b.
y-a.
y));
9864 nk_draw_list_path_line_to(list, a);
9865 nk_draw_list_path_line_to(list,
nk_vec2(b.
x,a.
y));
9866 nk_draw_list_path_line_to(list, b);
9867 nk_draw_list_path_line_to(list,
nk_vec2(a.
x,b.
y));
9869 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.
x + r, a.
y + r), r, 6, 9);
9870 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.
x - r, a.
y + r), r, 9, 12);
9871 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.
x - r, b.
y - r), r, 0, 3);
9872 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.
x + r, b.
y - r), r, 3, 6);
9876nk_draw_list_path_curve_to(
struct nk_draw_list *list,
struct nk_vec2 p2,
9880 unsigned int i_step;
9884 NK_ASSERT(list->path_count);
9885 if (!list || !list->path_count)
return;
9886 num_segments =
NK_MAX(num_segments, 1);
9888 p1 = nk_draw_list_path_last(list);
9889 t_step = 1.0f/(float)num_segments;
9890 for (i_step = 1; i_step <= num_segments; ++i_step) {
9891 float t = t_step * (float)i_step;
9896 float w4 = t * t *t;
9897 float x = w1 * p1.
x + w2 * p2.
x + w3 * p3.
x + w4 * p4.
x;
9898 float y = w1 * p1.
y + w2 * p2.
y + w3 * p3.
y + w4 * p4.
y;
9899 nk_draw_list_path_line_to(list,
nk_vec2(
x,
y));
9903nk_draw_list_path_fill(
struct nk_draw_list *list,
struct nk_color color)
9909 nk_draw_list_fill_poly_convex(list, points, list->path_count, color, list->config.shape_AA);
9910 nk_draw_list_path_clear(list);
9913nk_draw_list_path_stroke(
struct nk_draw_list *list,
struct nk_color color,
9914 enum nk_draw_list_stroke closed,
float thickness)
9920 nk_draw_list_stroke_poly_line(list, points, list->path_count, color,
9921 closed, thickness, list->config.line_AA);
9922 nk_draw_list_path_clear(list);
9925nk_draw_list_stroke_line(
struct nk_draw_list *list,
struct nk_vec2 a,
9929 if (!list || !col.
a)
return;
9931 nk_draw_list_path_line_to(list, a);
9932 nk_draw_list_path_line_to(list, b);
9937 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
9940nk_draw_list_fill_rect(
struct nk_draw_list *list,
struct nk_rect rect,
9941 struct nk_color col,
float rounding)
9944 if (!list || !col.
a)
return;
9947 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x, rect.
y),
9948 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
9950 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x-0.5f, rect.
y-0.5f),
9951 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
9952 } nk_draw_list_path_fill(list, col);
9955nk_draw_list_stroke_rect(
struct nk_draw_list *list,
struct nk_rect rect,
9956 struct nk_color col,
float rounding,
float thickness)
9959 if (!list || !col.
a)
return;
9961 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x, rect.
y),
9962 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
9964 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x-0.5f, rect.
y-0.5f),
9965 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
9966 } nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
9969nk_draw_list_fill_rect_multi_color(
struct nk_draw_list *list,
struct nk_rect rect,
9977 nk_draw_index index;
9987 nk_draw_list_push_image(list, list->config.null.texture);
9988 index = (nk_draw_index)list->vertex_count;
9989 vtx = nk_draw_list_alloc_vertices(list, 4);
9990 idx = nk_draw_list_alloc_elements(list, 6);
9991 if (!vtx || !idx)
return;
9993 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
9994 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
9995 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
9997 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y), list->config.null.uv, col_left);
9998 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y), list->config.null.uv, col_top);
9999 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), list->config.null.uv, col_right);
10000 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y + rect.
h), list->config.null.uv, col_bottom);
10003nk_draw_list_fill_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
10007 if (!list || !col.
a)
return;
10008 nk_draw_list_path_line_to(list,
a);
10009 nk_draw_list_path_line_to(list,
b);
10010 nk_draw_list_path_line_to(list, c);
10011 nk_draw_list_path_fill(list, col);
10014nk_draw_list_stroke_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
10018 if (!list || !col.
a)
return;
10019 nk_draw_list_path_line_to(list,
a);
10020 nk_draw_list_path_line_to(list,
b);
10021 nk_draw_list_path_line_to(list, c);
10022 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
10025nk_draw_list_fill_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
10026 float radius,
struct nk_color col,
unsigned int segs)
10030 if (!list || !col.
a)
return;
10031 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
10032 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
10033 nk_draw_list_path_fill(list, col);
10036nk_draw_list_stroke_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
10037 float radius,
struct nk_color col,
unsigned int segs,
float thickness)
10041 if (!list || !col.
a)
return;
10042 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
10043 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
10044 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
10047nk_draw_list_stroke_curve(
struct nk_draw_list *list,
struct nk_vec2 p0,
10049 struct nk_color col,
unsigned int segments,
float thickness)
10052 if (!list || !col.
a)
return;
10053 nk_draw_list_path_line_to(list, p0);
10054 nk_draw_list_path_curve_to(list, cp0, cp1, p1, segments);
10055 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
10058nk_draw_list_push_rect_uv(
struct nk_draw_list *list,
struct nk_vec2 a,
10069 nk_draw_index *idx;
10070 nk_draw_index index;
10080 index = (nk_draw_index)list->vertex_count;
10081 vtx = nk_draw_list_alloc_vertices(list, 4);
10082 idx = nk_draw_list_alloc_elements(list, 6);
10083 if (!vtx || !idx)
return;
10085 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
10086 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
10087 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
10089 vtx = nk_draw_vertex(vtx, &list->config,
a, uva, col);
10090 vtx = nk_draw_vertex(vtx, &list->config,
b, uvb, col);
10091 vtx = nk_draw_vertex(vtx, &list->config, c, uvc, col);
10092 vtx = nk_draw_vertex(vtx, &list->config, d, uvd, col);
10095nk_draw_list_add_image(
struct nk_draw_list *list,
struct nk_image texture,
10101 nk_draw_list_push_image(list, texture.
handle);
10105 uv[0].
x = (float)texture.
region[0]/(
float)texture.
w;
10106 uv[0].
y = (float)texture.
region[1]/(
float)texture.
h;
10107 uv[1].
x = (float)(texture.
region[0] + texture.
region[2])/(float)texture.
w;
10108 uv[1].y = (
float)(texture.
region[1] + texture.
region[3])/(
float)texture.
h;
10109 nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
10110 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), uv[0], uv[1], color);
10111 }
else nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
10116nk_draw_list_add_text(
struct nk_draw_list *list,
const struct nk_user_font *font,
10117 struct nk_rect rect,
const char *text,
int len,
float font_height,
10125 int next_glyph_len = 0;
10126 struct nk_user_font_glyph g;
10129 if (!list || !len || !text)
return;
10131 list->clip_rect.x, list->clip_rect.y, list->clip_rect.w, list->clip_rect.h))
return;
10133 nk_draw_list_push_image(list, font->texture);
10136 if (!glyph_len)
return;
10139 fg.
a = (
nk_byte)((
float)fg.
a * list->config.global_alpha);
10140 while (text_len < len && glyph_len) {
10141 float gx, gy, gh, gw;
10142 float char_width = 0;
10146 next_glyph_len =
nk_utf_decode(text + text_len + glyph_len, &next, (
int)len - text_len);
10147 font->query(font->
userdata, font_height, &g, unicode,
10151 gx = x + g.offset.x;
10152 gy = rect.
y + g.offset.y;
10153 gw = g.width; gh = g.height;
10154 char_width = g.xadvance;
10155 nk_draw_list_push_rect_uv(list,
nk_vec2(gx,gy),
nk_vec2(gx + gw, gy+ gh),
10156 g.uv[0], g.uv[1], fg);
10159 text_len += glyph_len;
10161 glyph_len = next_glyph_len;
10174 NK_ASSERT(vertices);
10175 NK_ASSERT(elements);
10179 if (!ctx || !cmds || !vertices || !elements || !config || !config->
vertex_layout)
10182 nk_draw_list_setup(&ctx->draw_list, config, cmds, vertices, elements,
10186#ifdef NK_INCLUDE_COMMAND_USERDATA
10187 ctx->draw_list.userdata = cmd->userdata;
10189 switch (cmd->
type) {
10193 nk_draw_list_add_clip(&ctx->draw_list,
nk_rect(s->
x, s->
y, s->
w, s->
h));
10209 nk_draw_list_stroke_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
10214 nk_draw_list_fill_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
10219 nk_draw_list_fill_rect_multi_color(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
10224 nk_draw_list_stroke_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
10225 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
10230 nk_draw_list_fill_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
10231 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
10236 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
10237 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
10239 nk_draw_list_path_stroke(&ctx->draw_list, c->
color, NK_STROKE_CLOSED, c->
line_thickness);
10243 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
10244 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
10246 nk_draw_list_path_fill(&ctx->draw_list, c->
color);
10250 nk_draw_list_stroke_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
10256 nk_draw_list_fill_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
10264 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
10266 nk_draw_list_path_stroke(&ctx->draw_list, p->
color, NK_STROKE_CLOSED, p->
line_thickness);
10273 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
10275 nk_draw_list_path_fill(&ctx->draw_list, p->
color);
10282 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
10288 nk_draw_list_add_text(&ctx->draw_list, t->
font,
nk_rect(t->
x, t->
y, t->
w, t->
h),
10293 nk_draw_list_add_image(&ctx->draw_list, i->
img,
nk_rect(i->
x, i->
y, i->
w, i->
h), i->
col);
10307NK_API const struct nk_draw_command*
10311 return nk__draw_list_begin(&ctx->draw_list, buffer);
10313NK_API const struct nk_draw_command*
10316 return nk__draw_list_end(&ctx->draw_list, buffer);
10318NK_API const struct nk_draw_command*
10319nk__draw_next(
const struct nk_draw_command *cmd,
10322 return nk__draw_list_next(cmd, buffer, &ctx->draw_list);
10329#ifdef NK_INCLUDE_FONT_BAKING
10337#define NK_RP__MAXVAL 0xffff
10338typedef unsigned short nk_rp_coord;
10353 struct nk_rp_node *next;
10356struct nk_rp_context {
10363 struct nk_rp_node *active_head;
10364 struct nk_rp_node *free_head;
10365 struct nk_rp_node extra[2];
10369struct nk_rp__findresult {
10371 struct nk_rp_node **prev_link;
10374enum NK_RP_HEURISTIC {
10375 NK_RP_HEURISTIC_Skyline_default=0,
10376 NK_RP_HEURISTIC_Skyline_BL_sortHeight = NK_RP_HEURISTIC_Skyline_default,
10377 NK_RP_HEURISTIC_Skyline_BF_sortHeight
10379enum NK_RP_INIT_STATE{NK_RP__INIT_skyline = 1};
10382nk_rp_setup_allow_out_of_mem(
struct nk_rp_context *context,
int allow_out_of_mem)
10384 if (allow_out_of_mem)
10389 context->align = 1;
10397 context->align = (context->width + context->num_nodes-1) / context->num_nodes;
10401nk_rp_init_target(
struct nk_rp_context *context,
int width,
int height,
10402 struct nk_rp_node *nodes,
int num_nodes)
10405#ifndef STBRP_LARGE_RECTS
10406 NK_ASSERT(width <= 0xffff && height <= 0xffff);
10409 for (i=0; i < num_nodes-1; ++i)
10410 nodes[i].next = &nodes[i+1];
10412 context->init_mode = NK_RP__INIT_skyline;
10413 context->heuristic = NK_RP_HEURISTIC_Skyline_default;
10414 context->free_head = &nodes[0];
10415 context->active_head = &context->extra[0];
10416 context->width = width;
10417 context->height = height;
10418 context->num_nodes = num_nodes;
10419 nk_rp_setup_allow_out_of_mem(context, 0);
10422 context->extra[0].x = 0;
10423 context->extra[0].y = 0;
10424 context->extra[0].next = &context->extra[1];
10425 context->extra[1].x = (nk_rp_coord) width;
10426 context->extra[1].y = 65535;
10427 context->extra[1].next = 0;
10431nk_rp__skyline_find_min_y(
struct nk_rp_context *c,
struct nk_rp_node *first,
10432 int x0,
int width,
int *pwaste)
10434 struct nk_rp_node *node = first;
10435 int x1 = x0 + width;
10436 int min_y, visited_width, waste_area;
10437 NK_ASSERT(first->x <= x0);
10440 NK_ASSERT(node->next->x > x0);
10442 NK_ASSERT(node->x <= x0);
10447 while (node->x < x1)
10449 if (node->y > min_y) {
10453 waste_area += visited_width * (node->y - min_y);
10457 visited_width += node->next->x - x0;
10459 visited_width += node->next->x - node->x;
10462 int under_width = node->next->x - node->x;
10463 if (under_width + visited_width > width)
10464 under_width = width - visited_width;
10465 waste_area += under_width * (min_y - node->y);
10466 visited_width += under_width;
10470 *pwaste = waste_area;
10474nk_rp__skyline_find_best_pos(struct nk_rp_context *c,
int width,
int height)
10476 int best_waste = (1<<30), best_x, best_y = (1 << 30);
10477 struct nk_rp__findresult fr;
10478 struct nk_rp_node **prev, *node, *tail, **best = 0;
10481 width = (width + c->align - 1);
10482 width -= width % c->align;
10483 NK_ASSERT(width % c->align == 0);
10485 node = c->active_head;
10486 prev = &c->active_head;
10487 while (node->x + width <= c->width) {
10489 y = nk_rp__skyline_find_min_y(c, node, node->x, width, &waste);
10491 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BL_sortHeight) {
10499 if (y + height <= c->height) {
10501 if (y < best_y || (y == best_y && waste < best_waste)) {
10503 best_waste = waste;
10508 prev = &node->next;
10511 best_x = (best == 0) ? 0 : (*best)->x;
10529 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BF_sortHeight)
10531 tail = c->active_head;
10532 node = c->active_head;
10533 prev = &c->active_head;
10535 while (tail->x < width)
10539 int xpos = tail->x - width;
10541 NK_ASSERT(xpos >= 0);
10543 while (node->next->x <= xpos) {
10544 prev = &node->next;
10547 NK_ASSERT(node->next->x > xpos && node->x <= xpos);
10548 y = nk_rp__skyline_find_min_y(c, node, xpos, width, &waste);
10549 if (y + height < c->height) {
10551 if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
10553 NK_ASSERT(y <= best_y);
10555 best_waste = waste;
10563 fr.prev_link = best;
10569nk_rp__skyline_pack_rectangle(struct nk_rp_context *context,
int width,
int height)
10572 struct nk_rp__findresult res = nk_rp__skyline_find_best_pos(context, width, height);
10573 struct nk_rp_node *node, *cur;
10579 if (res.prev_link == 0 || res.y + height > context->height || context->free_head == 0) {
10585 node = context->free_head;
10586 node->x = (nk_rp_coord) res.x;
10587 node->y = (nk_rp_coord) (res.y + height);
10589 context->free_head = node->next;
10594 cur = *res.prev_link;
10595 if (cur->x < res.x) {
10597 struct nk_rp_node *next = cur->next;
10601 *res.prev_link = node;
10606 while (cur->next && cur->next->x <= res.x + width) {
10607 struct nk_rp_node *next = cur->next;
10609 cur->next = context->free_head;
10610 context->free_head = cur;
10616 if (cur->x < res.x + width)
10617 cur->x = (nk_rp_coord) (res.x + width);
10621nk_rect_height_compare(
const void *a,
const void *b)
10623 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
10624 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
10629 return (p->w > q->w) ? -1 : (p->w < q->w);
10632nk_rect_original_order(
const void *a,
const void *b)
10634 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
10635 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
10636 return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
10639nk_rp_qsort(
struct nk_rp_rect *array,
unsigned int len,
int(*cmp)(
const void*,
const void*))
10642 #define NK_MAX_SORT_STACK 64
10643 unsigned right, left = 0, stack[NK_MAX_SORT_STACK], pos = 0;
10644 unsigned seed = len/2 * 69069+1;
10646 for (; left+1 < len; len++) {
10647 struct nk_rp_rect pivot, tmp;
10648 if (pos == NK_MAX_SORT_STACK) len = stack[pos = 0];
10649 pivot = array[left+seed%(len-left)];
10650 seed = seed * 69069 + 1;
10651 stack[pos++] = len;
10652 for (right = left-1;;) {
10653 while (cmp(&array[++right], &pivot) < 0);
10654 while (cmp(&pivot, &array[--len]) < 0);
10655 if (right >= len)
break;
10656 tmp = array[right];
10657 array[right] = array[len];
10661 if (pos == 0)
break;
10663 len = stack[--pos];
10665 #undef NK_MAX_SORT_STACK
10668nk_rp_pack_rects(
struct nk_rp_context *context,
struct nk_rp_rect *rects,
int num_rects)
10672 for (i=0; i < num_rects; ++i) {
10673 rects[i].was_packed = i;
10677 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_height_compare);
10679 for (i=0; i < num_rects; ++i) {
10680 struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
10681 if (fr.prev_link) {
10682 rects[i].x = (nk_rp_coord) fr.x;
10683 rects[i].y = (nk_rp_coord) fr.y;
10685 rects[i].x = rects[i].y = NK_RP__MAXVAL;
10690 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_original_order);
10693 for (i=0; i < num_rects; ++i)
10694 rects[i].was_packed = !(rects[i].x == NK_RP__MAXVAL && rects[i].y == NK_RP__MAXVAL);
10705#define NK_TT_MAX_OVERSAMPLE 8
10706#define NK_TT__OVER_MASK (NK_TT_MAX_OVERSAMPLE-1)
10708struct nk_tt_bakedchar {
10709 unsigned short x0,y0,x1,y1;
10711 float xoff,yoff,xadvance;
10714struct nk_tt_aligned_quad{
10719struct nk_tt_packedchar {
10720 unsigned short x0,y0,x1,y1;
10722 float xoff,yoff,xadvance;
10726struct nk_tt_pack_range {
10728 int first_unicode_codepoint_in_range;
10730 int *array_of_unicode_codepoints;
10733 struct nk_tt_packedchar *chardata_for_range;
10734 unsigned char h_oversample, v_oversample;
10738struct nk_tt_pack_context {
10742 int stride_in_bytes;
10744 unsigned int h_oversample, v_oversample;
10745 unsigned char *pixels;
10749struct nk_tt_fontinfo {
10750 const unsigned char* data;
10753 int loca,head,glyf,hhea,hmtx,kern;
10755 int indexToLocFormat;
10764struct nk_tt_vertex {
10766 unsigned char type,padding;
10769struct nk_tt__bitmap{
10771 unsigned char *pixels;
10774struct nk_tt__hheap_chunk {
10775 struct nk_tt__hheap_chunk *next;
10777struct nk_tt__hheap {
10779 struct nk_tt__hheap_chunk *head;
10781 int num_remaining_in_head_chunk;
10784struct nk_tt__edge {
10785 float x0,y0, x1,y1;
10789struct nk_tt__active_edge {
10790 struct nk_tt__active_edge *next;
10796struct nk_tt__point {
float x,y;};
10798#define NK_TT_MACSTYLE_DONTCARE 0
10799#define NK_TT_MACSTYLE_BOLD 1
10800#define NK_TT_MACSTYLE_ITALIC 2
10801#define NK_TT_MACSTYLE_UNDERSCORE 4
10802#define NK_TT_MACSTYLE_NONE 8
10806 NK_TT_PLATFORM_ID_UNICODE =0,
10807 NK_TT_PLATFORM_ID_MAC =1,
10808 NK_TT_PLATFORM_ID_ISO =2,
10809 NK_TT_PLATFORM_ID_MICROSOFT =3
10813 NK_TT_UNICODE_EID_UNICODE_1_0 =0,
10814 NK_TT_UNICODE_EID_UNICODE_1_1 =1,
10815 NK_TT_UNICODE_EID_ISO_10646 =2,
10816 NK_TT_UNICODE_EID_UNICODE_2_0_BMP=3,
10817 NK_TT_UNICODE_EID_UNICODE_2_0_FULL=4
10821 NK_TT_MS_EID_SYMBOL =0,
10822 NK_TT_MS_EID_UNICODE_BMP =1,
10823 NK_TT_MS_EID_SHIFTJIS =2,
10824 NK_TT_MS_EID_UNICODE_FULL =10
10828 NK_TT_MAC_EID_ROMAN =0, NK_TT_MAC_EID_ARABIC =4,
10829 NK_TT_MAC_EID_JAPANESE =1, NK_TT_MAC_EID_HEBREW =5,
10830 NK_TT_MAC_EID_CHINESE_TRAD =2, NK_TT_MAC_EID_GREEK =6,
10831 NK_TT_MAC_EID_KOREAN =3, NK_TT_MAC_EID_RUSSIAN =7
10836 NK_TT_MS_LANG_ENGLISH =0x0409, NK_TT_MS_LANG_ITALIAN =0x0410,
10837 NK_TT_MS_LANG_CHINESE =0x0804, NK_TT_MS_LANG_JAPANESE =0x0411,
10838 NK_TT_MS_LANG_DUTCH =0x0413, NK_TT_MS_LANG_KOREAN =0x0412,
10839 NK_TT_MS_LANG_FRENCH =0x040c, NK_TT_MS_LANG_RUSSIAN =0x0419,
10840 NK_TT_MS_LANG_GERMAN =0x0407, NK_TT_MS_LANG_SPANISH =0x0409,
10841 NK_TT_MS_LANG_HEBREW =0x040d, NK_TT_MS_LANG_SWEDISH =0x041D
10845 NK_TT_MAC_LANG_ENGLISH =0 , NK_TT_MAC_LANG_JAPANESE =11,
10846 NK_TT_MAC_LANG_ARABIC =12, NK_TT_MAC_LANG_KOREAN =23,
10847 NK_TT_MAC_LANG_DUTCH =4 , NK_TT_MAC_LANG_RUSSIAN =32,
10848 NK_TT_MAC_LANG_FRENCH =1 , NK_TT_MAC_LANG_SPANISH =6 ,
10849 NK_TT_MAC_LANG_GERMAN =2 , NK_TT_MAC_LANG_SWEDISH =5 ,
10850 NK_TT_MAC_LANG_HEBREW =10, NK_TT_MAC_LANG_CHINESE_SIMPLIFIED =33,
10851 NK_TT_MAC_LANG_ITALIAN =3 , NK_TT_MAC_LANG_CHINESE_TRAD =19
10854#define nk_ttBYTE(p) (* (const nk_byte *) (p))
10855#define nk_ttCHAR(p) (* (const char *) (p))
10857#if defined(NK_BIGENDIAN) && !defined(NK_ALLOW_UNALIGNED_TRUETYPE)
10858 #define nk_ttUSHORT(p) (* (nk_ushort *) (p))
10859 #define nk_ttSHORT(p) (* (nk_short *) (p))
10860 #define nk_ttULONG(p) (* (nk_uint *) (p))
10861 #define nk_ttLONG(p) (* (nk_int *) (p))
10865 static nk_uint nk_ttULONG(
const nk_byte *p) {
return (
nk_uint)((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]); }
10868#define nk_tt_tag4(p,c0,c1,c2,c3)\
10869 ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
10870#define nk_tt_tag(p,str) nk_tt_tag4(p,str[0],str[1],str[2],str[3])
10873 int glyph_index,
struct nk_tt_vertex **pvertices);
10876nk_tt__find_table(
const nk_byte *data,
nk_uint fontstart,
const char *tag)
10879 nk_int num_tables = nk_ttUSHORT(data+fontstart+4);
10880 nk_uint tabledir = fontstart + 12;
10882 for (i = 0; i < num_tables; ++i) {
10884 if (nk_tt_tag(data+loc+0, tag))
10885 return nk_ttULONG(data+loc+8);
10890nk_tt_InitFont(
struct nk_tt_fontinfo *info,
const unsigned char *data2,
int fontstart)
10897 info->fontstart = fontstart;
10899 cmap = nk_tt__find_table(data, (
nk_uint)fontstart,
"cmap");
10900 info->loca = (int)nk_tt__find_table(data, (
nk_uint)fontstart,
"loca");
10901 info->head = (int)nk_tt__find_table(data, (
nk_uint)fontstart,
"head");
10902 info->glyf = (int)nk_tt__find_table(data, (
nk_uint)fontstart,
"glyf");
10903 info->hhea = (int)nk_tt__find_table(data, (
nk_uint)fontstart,
"hhea");
10904 info->hmtx = (int)nk_tt__find_table(data, (
nk_uint)fontstart,
"hmtx");
10905 info->kern = (int)nk_tt__find_table(data, (
nk_uint)fontstart,
"kern");
10906 if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx)
10909 t = nk_tt__find_table(data, (
nk_uint)fontstart,
"maxp");
10910 if (t) info->numGlyphs = nk_ttUSHORT(data+t+4);
10911 else info->numGlyphs = 0xffff;
10916 numTables = nk_ttUSHORT(data + cmap + 2);
10917 info->index_map = 0;
10918 for (i=0; i < numTables; ++i)
10922 switch(nk_ttUSHORT(data+encoding_record)) {
10923 case NK_TT_PLATFORM_ID_MICROSOFT:
10924 switch (nk_ttUSHORT(data+encoding_record+2)) {
10925 case NK_TT_MS_EID_UNICODE_BMP:
10926 case NK_TT_MS_EID_UNICODE_FULL:
10928 info->index_map = (int)(cmap + nk_ttULONG(data+encoding_record+4));
10932 case NK_TT_PLATFORM_ID_UNICODE:
10935 info->index_map = (int)(cmap + nk_ttULONG(data+encoding_record+4));
10940 if (info->index_map == 0)
10942 info->indexToLocFormat = nk_ttUSHORT(data+info->head + 50);
10946nk_tt_FindGlyphIndex(
const struct nk_tt_fontinfo *info,
int unicode_codepoint)
10948 const nk_byte *data = info->data;
10951 nk_ushort format = nk_ttUSHORT(data + index_map + 0);
10953 nk_int bytes = nk_ttUSHORT(data + index_map + 2);
10954 if (unicode_codepoint < bytes-6)
10955 return nk_ttBYTE(data + index_map + 6 + unicode_codepoint);
10957 }
else if (format == 6) {
10958 nk_uint first = nk_ttUSHORT(data + index_map + 6);
10959 nk_uint count = nk_ttUSHORT(data + index_map + 8);
10960 if ((
nk_uint) unicode_codepoint >= first && (
nk_uint) unicode_codepoint < first+count)
10961 return nk_ttUSHORT(data + index_map + 10 + (unicode_codepoint - (
int)first)*2);
10963 }
else if (format == 2) {
10966 }
else if (format == 4) {
10967 nk_ushort segcount = nk_ttUSHORT(data+index_map+6) >> 1;
10968 nk_ushort searchRange = nk_ttUSHORT(data+index_map+8) >> 1;
10969 nk_ushort entrySelector = nk_ttUSHORT(data+index_map+10);
10970 nk_ushort rangeShift = nk_ttUSHORT(data+index_map+12) >> 1;
10973 nk_uint endCount = index_map + 14;
10976 if (unicode_codepoint > 0xffff)
10981 if (unicode_codepoint >= nk_ttUSHORT(data + search + rangeShift*2))
10982 search += (
nk_uint)(rangeShift*2);
10986 while (entrySelector) {
10989 end = nk_ttUSHORT(data + search + searchRange*2);
10990 if (unicode_codepoint > end)
10991 search += (
nk_uint)(searchRange*2);
11000 NK_ASSERT(unicode_codepoint <= nk_ttUSHORT(data + endCount + 2*item));
11001 start = nk_ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
11002 if (unicode_codepoint < start)
11005 offset = nk_ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
11007 return (
nk_ushort) (unicode_codepoint + nk_ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
11009 return nk_ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
11011 }
else if (format == 12 || format == 13) {
11012 nk_uint ngroups = nk_ttULONG(data+index_map+12);
11014 low = 0; high = (
nk_int)ngroups;
11016 while (low < high) {
11017 nk_int mid = low + ((high-low) >> 1);
11018 nk_uint start_char = nk_ttULONG(data+index_map+16+mid*12);
11019 nk_uint end_char = nk_ttULONG(data+index_map+16+mid*12+4);
11020 if ((
nk_uint) unicode_codepoint < start_char)
11022 else if ((
nk_uint) unicode_codepoint > end_char)
11025 nk_uint start_glyph = nk_ttULONG(data+index_map+16+mid*12+8);
11027 return (
int)start_glyph + (int)unicode_codepoint - (
int)start_char;
11029 return (
int)start_glyph;
11048nk_tt__GetGlyfOffset(
const struct nk_tt_fontinfo *info,
int glyph_index)
11051 if (glyph_index >= info->numGlyphs)
return -1;
11052 if (info->indexToLocFormat >= 2)
return -1;
11054 if (info->indexToLocFormat == 0) {
11055 g1 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
11056 g2 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
11058 g1 = info->glyf + (int)nk_ttULONG (info->data + info->loca + glyph_index * 4);
11059 g2 = info->glyf + (int)nk_ttULONG (info->data + info->loca + glyph_index * 4 + 4);
11061 return g1==g2 ? -1 : g1;
11064nk_tt_GetGlyphBox(
const struct nk_tt_fontinfo *info,
int glyph_index,
11065 int *x0,
int *y0,
int *x1,
int *y1)
11067 int g = nk_tt__GetGlyfOffset(info, glyph_index);
11068 if (g < 0)
return 0;
11070 if (x0) *x0 = nk_ttSHORT(info->data + g + 2);
11071 if (y0) *y0 = nk_ttSHORT(info->data + g + 4);
11072 if (x1) *x1 = nk_ttSHORT(info->data + g + 6);
11073 if (y1) *y1 = nk_ttSHORT(info->data + g + 8);
11077nk_tt__close_shape(
struct nk_tt_vertex *vertices,
int num_vertices,
int was_off,
11082 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
11083 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, sx,sy,scx,scy);
11086 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve,sx,sy,cx,cy);
11088 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline,sx,sy,0,0);
11090 return num_vertices;
11093nk_tt_GetGlyphShape(
const struct nk_tt_fontinfo *info,
struct nk_allocator *alloc,
11094 int glyph_index,
struct nk_tt_vertex **pvertices)
11097 const nk_byte *endPtsOfContours;
11098 const nk_byte *data = info->data;
11099 struct nk_tt_vertex *vertices=0;
11100 int num_vertices=0;
11101 int g = nk_tt__GetGlyfOffset(info, glyph_index);
11104 if (g < 0)
return 0;
11105 numberOfContours = nk_ttSHORT(data + g);
11106 if (numberOfContours > 0) {
11108 nk_int ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0;
11109 nk_int x,y,cx,cy,sx,sy, scx,scy;
11111 endPtsOfContours = (data + g + 10);
11112 ins = nk_ttUSHORT(data + g + 10 + numberOfContours * 2);
11113 points = data + g + 10 + numberOfContours * 2 + 2 + ins;
11115 n = 1+nk_ttUSHORT(endPtsOfContours + numberOfContours*2-2);
11116 m = n + 2*numberOfContours;
11117 vertices = (
struct nk_tt_vertex *)alloc->
alloc(alloc->
userdata, 0, (
nk_size)m *
sizeof(vertices[0]));
11130 for (i=0; i < n; ++i) {
11131 if (flagcount == 0) {
11134 flagcount = *points++;
11135 }
else --flagcount;
11136 vertices[off+i].type = flags;
11141 for (i=0; i < n; ++i) {
11142 flags = vertices[off+i].type;
11145 x += (flags & 16) ? dx : -dx;
11147 if (!(flags & 16)) {
11148 x = x + (
nk_short) (points[0]*256 + points[1]);
11157 for (i=0; i < n; ++i) {
11158 flags = vertices[off+i].type;
11161 y += (flags & 32) ? dy : -dy;
11163 if (!(flags & 32)) {
11164 y = y + (
nk_short) (points[0]*256 + points[1]);
11173 sx = sy = cx = cy = scx = scy = 0;
11174 for (i=0; i < n; ++i)
11176 flags = vertices[off+i].type;
11180 if (next_move == i) {
11182 num_vertices = nk_tt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
11185 start_off = !(flags & 1);
11191 if (!(vertices[off+i+1].type & 1)) {
11193 sx = (x + (
nk_int) vertices[off+i+1].x) >> 1;
11194 sy = (y + (
nk_int) vertices[off+i+1].y) >> 1;
11197 sx = (
nk_int) vertices[off+i+1].x;
11198 sy = (
nk_int) vertices[off+i+1].y;
11205 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vmove,sx,sy,0,0);
11207 next_move = 1 + nk_ttUSHORT(endPtsOfContours+j*2);
11213 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
11219 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, x,y, cx, cy);
11220 else nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline, x,y,0,0);
11225 num_vertices = nk_tt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
11226 }
else if (numberOfContours == -1) {
11229 const nk_byte *comp = data + g + 10;
11236 int comp_num_verts = 0, i;
11237 struct nk_tt_vertex *comp_verts = 0, *tmp = 0;
11238 float mtx[6] = {1,0,0,1,0,0}, m, n;
11240 flags = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
11241 gidx = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
11245 mtx[4] = nk_ttSHORT(comp); comp+=2;
11246 mtx[5] = nk_ttSHORT(comp); comp+=2;
11248 mtx[4] = nk_ttCHAR(comp); comp+=1;
11249 mtx[5] = nk_ttCHAR(comp); comp+=1;
11255 if (flags & (1<<3)) {
11256 mtx[0] = mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11257 mtx[1] = mtx[2] = 0;
11258 }
else if (flags & (1<<6)) {
11259 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11260 mtx[1] = mtx[2] = 0;
11261 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11262 }
else if (flags & (1<<7)) {
11263 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11264 mtx[1] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11265 mtx[2] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11266 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11270 m = (float) NK_SQRT(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
11271 n = (float) NK_SQRT(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
11274 comp_num_verts = nk_tt_GetGlyphShape(info, alloc, gidx, &comp_verts);
11275 if (comp_num_verts > 0)
11278 for (i = 0; i < comp_num_verts; ++i) {
11279 struct nk_tt_vertex* v = &comp_verts[i];
11282 v->x = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
11283 v->y = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
11285 v->cx = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
11286 v->cy = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
11289 tmp = (
struct nk_tt_vertex*)alloc->
alloc(alloc->
userdata, 0,
11290 (
nk_size)(num_vertices+comp_num_verts)*
sizeof(
struct nk_tt_vertex));
11293 if (comp_verts) alloc->
free(alloc->
userdata, comp_verts);
11296 if (num_vertices > 0) NK_MEMCPY(tmp, vertices, (
nk_size)num_vertices*
sizeof(
struct nk_tt_vertex));
11297 NK_MEMCPY(tmp+num_vertices, comp_verts, (
nk_size)comp_num_verts*
sizeof(
struct nk_tt_vertex));
11301 num_vertices += comp_num_verts;
11304 more = flags & (1<<5);
11306 }
else if (numberOfContours < 0) {
11312 *pvertices = vertices;
11313 return num_vertices;
11316nk_tt_GetGlyphHMetrics(
const struct nk_tt_fontinfo *info,
int glyph_index,
11317 int *advanceWidth,
int *leftSideBearing)
11319 nk_ushort numOfLongHorMetrics = nk_ttUSHORT(info->data+info->hhea + 34);
11320 if (glyph_index < numOfLongHorMetrics) {
11322 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index);
11323 if (leftSideBearing)
11324 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
11327 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
11328 if (leftSideBearing)
11329 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
11333nk_tt_GetFontVMetrics(
const struct nk_tt_fontinfo *info,
11334 int *ascent,
int *descent,
int *lineGap)
11336 if (ascent ) *ascent = nk_ttSHORT(info->data+info->hhea + 4);
11337 if (descent) *descent = nk_ttSHORT(info->data+info->hhea + 6);
11338 if (lineGap) *lineGap = nk_ttSHORT(info->data+info->hhea + 8);
11341nk_tt_ScaleForPixelHeight(
const struct nk_tt_fontinfo *info,
float height)
11343 int fheight = nk_ttSHORT(info->data + info->hhea + 4) - nk_ttSHORT(info->data + info->hhea + 6);
11344 return (
float) height / (float)fheight;
11347nk_tt_ScaleForMappingEmToPixels(
const struct nk_tt_fontinfo *info,
float pixels)
11349 int unitsPerEm = nk_ttUSHORT(info->data + info->head + 18);
11350 return pixels / (float)unitsPerEm;
11357nk_tt_GetGlyphBitmapBoxSubpixel(
const struct nk_tt_fontinfo *font,
11358 int glyph,
float scale_x,
float scale_y,
float shift_x,
float shift_y,
11359 int *ix0,
int *iy0,
int *ix1,
int *iy1)
11362 if (!nk_tt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
11370 if (ix0) *ix0 = nk_ifloorf((
float)x0 * scale_x + shift_x);
11371 if (iy0) *iy0 = nk_ifloorf((
float)-y1 * scale_y + shift_y);
11372 if (ix1) *ix1 = nk_iceilf ((
float)x1 * scale_x + shift_x);
11373 if (iy1) *iy1 = nk_iceilf ((
float)-y0 * scale_y + shift_y);
11377nk_tt_GetGlyphBitmapBox(
const struct nk_tt_fontinfo *font,
int glyph,
11378 float scale_x,
float scale_y,
int *ix0,
int *iy0,
int *ix1,
int *iy1)
11380 nk_tt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
11387nk_tt__hheap_alloc(
struct nk_tt__hheap *hh,
nk_size size)
11389 if (hh->first_free) {
11390 void *p = hh->first_free;
11391 hh->first_free = * (
void **) p;
11394 if (hh->num_remaining_in_head_chunk == 0) {
11395 int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
11396 struct nk_tt__hheap_chunk *c = (
struct nk_tt__hheap_chunk *)
11397 hh->alloc.alloc(hh->alloc.userdata, 0,
11398 sizeof(
struct nk_tt__hheap_chunk) + size * (
nk_size)count);
11399 if (c == 0)
return 0;
11400 c->next = hh->head;
11402 hh->num_remaining_in_head_chunk = count;
11404 --hh->num_remaining_in_head_chunk;
11405 return (
char *) (hh->head) + size * (
nk_size)hh->num_remaining_in_head_chunk;
11409nk_tt__hheap_free(
struct nk_tt__hheap *hh,
void *p)
11411 *(
void **) p = hh->first_free;
11412 hh->first_free = p;
11415nk_tt__hheap_cleanup(
struct nk_tt__hheap *hh)
11417 struct nk_tt__hheap_chunk *c = hh->head;
11419 struct nk_tt__hheap_chunk *n = c->next;
11420 hh->alloc.free(hh->alloc.userdata, c);
11425nk_tt__new_active(
struct nk_tt__hheap *hh,
struct nk_tt__edge *e,
11426 int off_x,
float start_point)
11428 struct nk_tt__active_edge *z = (
struct nk_tt__active_edge *)
11429 nk_tt__hheap_alloc(hh,
sizeof(*z));
11430 float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
11434 z->fdy = (dxdy != 0) ? (1/dxdy): 0;
11435 z->fx = e->x0 + dxdy * (start_point - e->y0);
11436 z->fx -= (float)off_x;
11437 z->direction = e->invert ? 1.0f : -1.0f;
11444nk_tt__handle_clipped_edge(
float *scanline,
int x,
struct nk_tt__active_edge *e,
11445 float x0,
float y0,
float x1,
float y1)
11447 if (y0 == y1)
return;
11448 NK_ASSERT(y0 < y1);
11449 NK_ASSERT(e->sy <= e->ey);
11450 if (y0 > e->ey)
return;
11451 if (y1 < e->sy)
return;
11453 x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
11457 x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
11461 if (x0 == x) NK_ASSERT(x1 <= x+1);
11462 else if (x0 == x+1) NK_ASSERT(x1 >= x);
11463 else if (x0 <= x) NK_ASSERT(x1 <= x);
11464 else if (x0 >= x+1) NK_ASSERT(x1 >= x+1);
11465 else NK_ASSERT(x1 >= x && x1 <= x+1);
11467 if (x0 <= x && x1 <= x)
11468 scanline[x] += e->direction * (y1-y0);
11469 else if (x0 >= x+1 && x1 >= x+1);
11471 NK_ASSERT(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
11473 scanline[x] += (float)e->direction * (
float)(y1-y0) * (1.0f-((x0-(
float)x)+(x1-(float)x))/2.0f);
11477nk_tt__fill_active_edges_new(
float *scanline,
float *scanline_fill,
int len,
11478 struct nk_tt__active_edge *e,
float y_top)
11480 float y_bottom = y_top+1;
11485 NK_ASSERT(e->ey >= y_top);
11490 nk_tt__handle_clipped_edge(scanline,(
int) x0,e, x0,y_top, x0,y_bottom);
11491 nk_tt__handle_clipped_edge(scanline_fill-1,(
int) x0+1,e, x0,y_top, x0,y_bottom);
11493 nk_tt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
11499 float xb = x0 + dx;
11500 float x_top, x_bottom;
11503 NK_ASSERT(e->sy <= y_bottom && e->ey >= y_top);
11508 if (e->sy > y_top) {
11509 x_top = x0 + dx * (e->sy - y_top);
11516 if (e->ey < y_bottom) {
11517 x_bottom = x0 + dx * (e->ey - y_top);
11524 if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len)
11527 if ((
int) x_top == (int) x_bottom) {
11530 int x = (int) x_top;
11532 NK_ASSERT(x >= 0 && x < len);
11533 scanline[x] += e->direction * (1.0f-(((float)x_top - (
float)x) + ((
float)x_bottom-(float)x))/2.0f) * (float)height;
11534 scanline_fill[x] += e->direction * (float)height;
11537 float y_crossing, step, sign, area;
11539 if (x_top > x_bottom)
11543 y0 = y_bottom - (y0 - y_top);
11544 y1 = y_bottom - (y1 - y_top);
11545 t = y0; y0 = y1; y1 = t;
11546 t = x_bottom; x_bottom = x_top; x_top = t;
11549 t = x0; x0 = xb; xb = t;
11553 x2 = (int) x_bottom;
11555 y_crossing = ((float)x1+1 - (
float)x0) * (
float)dy + (float)y_top;
11557 sign = e->direction;
11559 area = sign * (y_crossing-y0);
11561 scanline[x1] += area * (1.0f-((float)((
float)x_top - (float)x1)+(float)(x1+1-x1))/2.0f);
11564 for (x = x1+1; x < x2; ++x) {
11565 scanline[x] += area + step/2;
11568 y_crossing += (float)dy * (
float)(x2 - (x1+1));
11570 scanline[x2] += area + sign * (1.0f-((float)(x2-x2)+((float)x_bottom-(
float)x2))/2.0f) * (y1-y_crossing);
11571 scanline_fill[x2] += sign * (y1-y0);
11581 for (x=0; x < len; ++x)
11598 float x1 = (float) (x);
11599 float x2 = (float) (x+1);
11601 float y3 = y_bottom;
11604 yb = ((float)x - x0) / dx + y_top;
11605 y2 = ((float)x+1 - x0) / dx + y_top;
11607 if (x0 < x1 && x3 > x2) {
11608 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
11609 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x2,y2);
11610 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
11611 }
else if (x3 < x1 && x0 > x2) {
11612 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
11613 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x1,yb);
11614 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
11615 }
else if (x0 < x1 && x3 > x1) {
11616 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
11617 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
11618 }
else if (x3 < x1 && x0 > x1) {
11619 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
11620 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
11621 }
else if (x0 < x2 && x3 > x2) {
11622 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
11623 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
11624 }
else if (x3 < x2 && x0 > x2) {
11625 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
11626 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
11628 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x3,y3);
11637nk_tt__rasterize_sorted_edges(
struct nk_tt__bitmap *result,
struct nk_tt__edge *e,
11638 int n,
int vsubsample,
int off_x,
int off_y,
struct nk_allocator *alloc)
11641 struct nk_tt__hheap hh;
11642 struct nk_tt__active_edge *active = 0;
11644 float scanline_data[129], *scanline, *scanline2;
11650 if (result->w > 64)
11651 scanline = (
float *) alloc->
alloc(alloc->
userdata,0, (
nk_size)(result->w*2+1) *
sizeof(
float));
11652 else scanline = scanline_data;
11654 scanline2 = scanline + result->w;
11656 e[n].y0 = (float) (off_y + result->h) + 1;
11658 while (j < result->h)
11661 float scan_y_top = (float)y + 0.0f;
11662 float scan_y_bottom = (float)y + 1.0f;
11663 struct nk_tt__active_edge **step = &active;
11665 NK_MEMSET(scanline , 0, (
nk_size)result->w*
sizeof(scanline[0]));
11666 NK_MEMSET(scanline2, 0, (
nk_size)(result->w+1)*
sizeof(scanline[0]));
11671 struct nk_tt__active_edge * z = *step;
11672 if (z->ey <= scan_y_top) {
11674 NK_ASSERT(z->direction);
11676 nk_tt__hheap_free(&hh, z);
11678 step = &((*step)->next);
11683 while (e->y0 <= scan_y_bottom) {
11684 if (e->y0 != e->y1) {
11685 struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
11687 NK_ASSERT(z->ey >= scan_y_top);
11698 nk_tt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
11702 for (i=0; i < result->w; ++i) {
11705 sum += scanline2[i];
11706 k = scanline[i] + sum;
11707 k = (float)
NK_ABS(k) * 255.0f + 0.5f;
11709 if (m > 255) m = 255;
11710 result->pixels[j*result->stride + i] = (
unsigned char) m;
11716 struct nk_tt__active_edge *z = *step;
11718 step = &((*step)->next);
11723 nk_tt__hheap_cleanup(&hh);
11724 if (scanline != scanline_data)
11728nk_tt__sort_edges_ins_sort(
struct nk_tt__edge *p,
int n)
11731 #define NK_TT__COMPARE(a,b) ((a)->y0 < (b)->y0)
11732 for (i=1; i < n; ++i) {
11733 struct nk_tt__edge t = p[i], *a = &t;
11736 struct nk_tt__edge *b = &p[j-1];
11737 int c = NK_TT__COMPARE(a,b);
11747nk_tt__sort_edges_quicksort(
struct nk_tt__edge *p,
int n)
11751 struct nk_tt__edge t;
11752 int c01,c12,c,m,i,j;
11756 c01 = NK_TT__COMPARE(&p[0],&p[m]);
11757 c12 = NK_TT__COMPARE(&p[m],&p[n-1]);
11763 c = NK_TT__COMPARE(&p[0],&p[n-1]);
11766 z = (c == c12) ? 0 : n-1;
11785 if (!NK_TT__COMPARE(&p[i], &p[0]))
break;
11788 if (!NK_TT__COMPARE(&p[0], &p[j]))
break;
11804 nk_tt__sort_edges_quicksort(p,j);
11808 nk_tt__sort_edges_quicksort(p+i, n-i);
11814nk_tt__sort_edges(
struct nk_tt__edge *p,
int n)
11816 nk_tt__sort_edges_quicksort(p, n);
11817 nk_tt__sort_edges_ins_sort(p, n);
11820nk_tt__rasterize(
struct nk_tt__bitmap *result,
struct nk_tt__point *pts,
11821 int *wcount,
int windings,
float scale_x,
float scale_y,
11822 float shift_x,
float shift_y,
int off_x,
int off_y,
int invert,
11825 float y_scale_inv = invert ? -scale_y : scale_y;
11826 struct nk_tt__edge *e;
11828 int vsubsample = 1;
11833 for (i=0; i < windings; ++i)
11836 e = (
struct nk_tt__edge*)
11838 if (e == 0)
return;
11842 for (i=0; i < windings; ++i)
11844 struct nk_tt__point *p = pts + m;
11847 for (k=0; k < wcount[i]; j=k++) {
11850 if (p[j].y == p[k].y)
11855 if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
11859 e[n].x0 = p[a].x * scale_x + shift_x;
11860 e[n].y0 = (p[a].y * y_scale_inv + shift_y) * (
float)vsubsample;
11861 e[n].x1 = p[b].x * scale_x + shift_x;
11862 e[n].y1 = (p[b].y * y_scale_inv + shift_y) * (
float)vsubsample;
11869 nk_tt__sort_edges(e, n);
11871 nk_tt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, alloc);
11875nk_tt__add_point(
struct nk_tt__point *points,
int n,
float x,
float y)
11877 if (!points)
return;
11882nk_tt__tesselate_curve(
struct nk_tt__point *points,
int *num_points,
11883 float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
11884 float objspace_flatness_squared,
int n)
11889 float mx = (x0 + 2*x1 + x2)/4;
11890 float my = (y0 + 2*y1 + y2)/4;
11892 float dx = (x0+x2)/2 - mx;
11893 float dy = (y0+y2)/2 - my;
11898 if (dx*dx+dy*dy > objspace_flatness_squared) {
11899 nk_tt__tesselate_curve(points, num_points, x0,y0,
11900 (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
11901 nk_tt__tesselate_curve(points, num_points, mx,my,
11902 (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
11904 nk_tt__add_point(points, *num_points,x2,y2);
11905 *num_points = *num_points+1;
11910nk_tt_FlattenCurves(
struct nk_tt_vertex *vertices,
int num_verts,
11911 float objspace_flatness,
int **contour_lengths,
int *num_contours,
11915 struct nk_tt__point *points=0;
11917 float objspace_flatness_squared = objspace_flatness * objspace_flatness;
11924 for (i=0; i < num_verts; ++i)
11925 if (vertices[i].type == NK_TT_vmove) ++n;
11928 if (n == 0)
return 0;
11930 *contour_lengths = (
int *)
11932 if (*contour_lengths == 0) {
11938 for (pass=0; pass < 2; ++pass)
11942 points = (
struct nk_tt__point *)
11944 if (points == 0)
goto error;
11949 for (i=0; i < num_verts; ++i)
11951 switch (vertices[i].type) {
11955 (*contour_lengths)[n] = num_points - start;
11957 start = num_points;
11959 x = vertices[i].x, y = vertices[i].y;
11960 nk_tt__add_point(points, num_points++, x,y);
11963 x = vertices[i].x, y = vertices[i].y;
11964 nk_tt__add_point(points, num_points++, x, y);
11967 nk_tt__tesselate_curve(points, &num_points, x,y,
11968 vertices[i].cx, vertices[i].cy,
11969 vertices[i].x, vertices[i].y,
11970 objspace_flatness_squared, 0);
11971 x = vertices[i].x, y = vertices[i].y;
11976 (*contour_lengths)[n] = num_points - start;
11983 *contour_lengths = 0;
11988nk_tt_Rasterize(
struct nk_tt__bitmap *result,
float flatness_in_pixels,
11989 struct nk_tt_vertex *vertices,
int num_verts,
11990 float scale_x,
float scale_y,
float shift_x,
float shift_y,
11991 int x_off,
int y_off,
int invert,
struct nk_allocator *alloc)
11993 float scale = scale_x > scale_y ? scale_y : scale_x;
11994 int winding_count, *winding_lengths;
11995 struct nk_tt__point *windings = nk_tt_FlattenCurves(vertices, num_verts,
11996 flatness_in_pixels / scale, &winding_lengths, &winding_count, alloc);
12000 nk_tt__rasterize(result, windings, winding_lengths, winding_count,
12001 scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, alloc);
12007nk_tt_MakeGlyphBitmapSubpixel(
const struct nk_tt_fontinfo *info,
unsigned char *output,
12008 int out_w,
int out_h,
int out_stride,
float scale_x,
float scale_y,
12009 float shift_x,
float shift_y,
int glyph,
struct nk_allocator *alloc)
12012 struct nk_tt_vertex *vertices;
12013 int num_verts = nk_tt_GetGlyphShape(info, alloc, glyph, &vertices);
12014 struct nk_tt__bitmap gbm;
12016 nk_tt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x,
12017 shift_y, &ix0,&iy0,0,0);
12018 gbm.pixels = output;
12021 gbm.stride = out_stride;
12023 if (gbm.w && gbm.h)
12024 nk_tt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y,
12025 shift_x, shift_y, ix0,iy0, 1, alloc);
12033nk_tt_PackBegin(
struct nk_tt_pack_context *spc,
unsigned char *pixels,
12034 int pw,
int ph,
int stride_in_bytes,
int padding,
struct nk_allocator *alloc)
12036 int num_nodes = pw - padding;
12037 struct nk_rp_context *context = (
struct nk_rp_context *)
12039 struct nk_rp_node *nodes = (
struct nk_rp_node*)
12042 if (context == 0 || nodes == 0) {
12043 if (context != 0) alloc->
free(alloc->
userdata, context);
12050 spc->pixels = pixels;
12051 spc->pack_info = context;
12052 spc->nodes = nodes;
12053 spc->padding = padding;
12054 spc->stride_in_bytes = (stride_in_bytes != 0) ? stride_in_bytes : pw;
12055 spc->h_oversample = 1;
12056 spc->v_oversample = 1;
12058 nk_rp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
12060 NK_MEMSET(pixels, 0, (
nk_size)(pw*ph));
12064nk_tt_PackEnd(
struct nk_tt_pack_context *spc,
struct nk_allocator *alloc)
12070nk_tt_PackSetOversampling(
struct nk_tt_pack_context *spc,
12071 unsigned int h_oversample,
unsigned int v_oversample)
12073 NK_ASSERT(h_oversample <= NK_TT_MAX_OVERSAMPLE);
12074 NK_ASSERT(v_oversample <= NK_TT_MAX_OVERSAMPLE);
12075 if (h_oversample <= NK_TT_MAX_OVERSAMPLE)
12076 spc->h_oversample = h_oversample;
12077 if (v_oversample <= NK_TT_MAX_OVERSAMPLE)
12078 spc->v_oversample = v_oversample;
12081nk_tt__h_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
12084 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
12085 int safe_w = w - kernel_width;
12088 for (j=0; j < h; ++j)
12091 unsigned int total;
12092 NK_MEMSET(buffer, 0, (
nk_size)kernel_width);
12097 switch (kernel_width) {
12099 for (i=0; i <= safe_w; ++i) {
12100 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12101 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12102 pixels[i] = (
unsigned char) (total / 2);
12106 for (i=0; i <= safe_w; ++i) {
12107 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12108 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12109 pixels[i] = (
unsigned char) (total / 3);
12113 for (i=0; i <= safe_w; ++i) {
12114 total += (
unsigned int)pixels[i] - buffer[i & NK_TT__OVER_MASK];
12115 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12116 pixels[i] = (
unsigned char) (total / 4);
12120 for (i=0; i <= safe_w; ++i) {
12121 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12122 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12123 pixels[i] = (
unsigned char) (total / 5);
12127 for (i=0; i <= safe_w; ++i) {
12128 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12129 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12130 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
12135 for (; i < w; ++i) {
12136 NK_ASSERT(pixels[i] == 0);
12137 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
12138 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
12140 pixels += stride_in_bytes;
12144nk_tt__v_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
12147 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
12148 int safe_h = h - kernel_width;
12151 for (j=0; j < w; ++j)
12154 unsigned int total;
12155 NK_MEMSET(buffer, 0, (
nk_size)kernel_width);
12160 switch (kernel_width) {
12162 for (i=0; i <= safe_h; ++i) {
12163 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12164 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12165 pixels[i*stride_in_bytes] = (
unsigned char) (total / 2);
12169 for (i=0; i <= safe_h; ++i) {
12170 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12171 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12172 pixels[i*stride_in_bytes] = (
unsigned char) (total / 3);
12176 for (i=0; i <= safe_h; ++i) {
12177 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12178 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12179 pixels[i*stride_in_bytes] = (
unsigned char) (total / 4);
12183 for (i=0; i <= safe_h; ++i) {
12184 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12185 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12186 pixels[i*stride_in_bytes] = (
unsigned char) (total / 5);
12190 for (i=0; i <= safe_h; ++i) {
12191 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12192 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12193 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
12198 for (; i < h; ++i) {
12199 NK_ASSERT(pixels[i*stride_in_bytes] == 0);
12200 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
12201 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
12207nk_tt__oversample_shift(
int oversample)
12216 return (
float)-(oversample - 1) / (2.0f * (
float)oversample);
12219nk_tt_PackFontRangesGatherRects(
struct nk_tt_pack_context *spc,
12220 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
12221 int num_ranges,
struct nk_rp_rect *rects)
12227 for (i=0; i < num_ranges; ++i) {
12228 float fh = ranges[i].font_size;
12229 float scale = (fh > 0) ? nk_tt_ScaleForPixelHeight(info, fh):
12230 nk_tt_ScaleForMappingEmToPixels(info, -fh);
12231 ranges[i].h_oversample = (
unsigned char) spc->h_oversample;
12232 ranges[i].v_oversample = (
unsigned char) spc->v_oversample;
12233 for (j=0; j < ranges[i].num_chars; ++j) {
12235 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
12236 ranges[i].first_unicode_codepoint_in_range + j :
12237 ranges[i].array_of_unicode_codepoints[j];
12239 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
12240 nk_tt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * (
float)spc->h_oversample,
12241 scale * (
float)spc->v_oversample, 0,0, &x0,&y0,&x1,&y1);
12242 rects[k].w = (nk_rp_coord) (x1-x0 + spc->padding + (
int)spc->h_oversample-1);
12243 rects[k].h = (nk_rp_coord) (y1-y0 + spc->padding + (
int)spc->v_oversample-1);
12250nk_tt_PackFontRangesRenderIntoRects(
struct nk_tt_pack_context *spc,
12251 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
12252 int num_ranges,
struct nk_rp_rect *rects,
struct nk_allocator *alloc)
12254 int i,j,k, return_value = 1;
12256 int old_h_over = (int)spc->h_oversample;
12257 int old_v_over = (
int)spc->v_oversample;
12261 for (i=0; i < num_ranges; ++i)
12263 float fh = ranges[i].font_size;
12264 float recip_h,recip_v,sub_x,sub_y;
12265 float scale = fh > 0 ? nk_tt_ScaleForPixelHeight(info, fh):
12266 nk_tt_ScaleForMappingEmToPixels(info, -fh);
12268 spc->h_oversample = ranges[i].h_oversample;
12269 spc->v_oversample = ranges[i].v_oversample;
12271 recip_h = 1.0f / (float)spc->h_oversample;
12272 recip_v = 1.0f / (
float)spc->v_oversample;
12274 sub_x = nk_tt__oversample_shift((
int)spc->h_oversample);
12275 sub_y = nk_tt__oversample_shift((
int)spc->v_oversample);
12277 for (j=0; j < ranges[i].num_chars; ++j)
12279 struct nk_rp_rect *r = &rects[k];
12282 struct nk_tt_packedchar *bc = &ranges[i].chardata_for_range[j];
12283 int advance, lsb, x0,y0,x1,y1;
12284 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
12285 ranges[i].first_unicode_codepoint_in_range + j :
12286 ranges[i].array_of_unicode_codepoints[j];
12287 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
12288 nk_rp_coord pad = (nk_rp_coord) spc->padding;
12291 r->x = (nk_rp_coord)((int)r->x + (
int)pad);
12292 r->y = (nk_rp_coord)((
int)r->y + (int)pad);
12293 r->w = (nk_rp_coord)((
int)r->w - (int)pad);
12294 r->h = (nk_rp_coord)((
int)r->h - (int)pad);
12296 nk_tt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
12297 nk_tt_GetGlyphBitmapBox(info, glyph, scale * (
float)spc->h_oversample,
12298 (scale * (
float)spc->v_oversample), &x0,&y0,&x1,&y1);
12299 nk_tt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes,
12300 (
int)(r->w - spc->h_oversample+1), (
int)(r->h - spc->v_oversample+1),
12301 spc->stride_in_bytes, scale * (
float)spc->h_oversample,
12302 scale * (
float)spc->v_oversample, 0,0, glyph, alloc);
12304 if (spc->h_oversample > 1)
12305 nk_tt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
12306 r->w, r->h, spc->stride_in_bytes, (
int)spc->h_oversample);
12308 if (spc->v_oversample > 1)
12309 nk_tt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
12310 r->w, r->h, spc->stride_in_bytes, (
int)spc->v_oversample);
12316 bc->xadvance = scale * (float)advance;
12317 bc->xoff = (float) x0 * recip_h + sub_x;
12318 bc->yoff = (float) y0 * recip_v + sub_y;
12319 bc->xoff2 = ((float)x0 + r->w) * recip_h + sub_x;
12320 bc->yoff2 = ((float)y0 + r->h) * recip_v + sub_y;
12328 spc->h_oversample = (
unsigned int)old_h_over;
12329 spc->v_oversample = (
unsigned int)old_v_over;
12330 return return_value;
12333nk_tt_GetPackedQuad(
struct nk_tt_packedchar *chardata,
int pw,
int ph,
12334 int char_index,
float *xpos,
float *ypos,
struct nk_tt_aligned_quad *q,
12335 int align_to_integer)
12337 float ipw = 1.0f / (float)pw, iph = 1.0f / (
float)ph;
12338 struct nk_tt_packedchar *b = (
struct nk_tt_packedchar*)(chardata + char_index);
12339 if (align_to_integer) {
12340 int tx = nk_ifloorf((*xpos + b->xoff) + 0.5f);
12341 int ty = nk_ifloorf((*ypos + b->yoff) + 0.5f);
12343 float x = (float)tx;
12344 float y = (float)ty;
12348 q->x1 = x + b->xoff2 - b->xoff;
12349 q->y1 = y + b->yoff2 - b->yoff;
12351 q->x0 = *xpos + b->xoff;
12352 q->y0 = *ypos + b->yoff;
12353 q->x1 = *xpos + b->xoff2;
12354 q->y1 = *ypos + b->yoff2;
12356 q->s0 = b->x0 * ipw;
12357 q->t0 = b->y0 * iph;
12358 q->s1 = b->x1 * ipw;
12359 q->t1 = b->y1 * iph;
12360 *xpos += b->xadvance;
12368struct nk_font_bake_data {
12369 struct nk_tt_fontinfo info;
12370 struct nk_rp_rect *rects;
12371 struct nk_tt_pack_range *ranges;
12375struct nk_font_baker {
12377 struct nk_tt_pack_context spc;
12378 struct nk_font_bake_data *build;
12379 struct nk_tt_packedchar *packed_chars;
12380 struct nk_rp_rect *rects;
12381 struct nk_tt_pack_range *ranges;
12391nk_range_count(
const nk_rune *range)
12395 if (!range)
return 0;
12396 while (*(iter++) != 0);
12397 return (iter == range) ? 0 : (int)((iter - range)/2);
12400nk_range_glyph_count(
const nk_rune *range,
int count)
12403 int total_glyphs = 0;
12404 for (i = 0; i < count; ++i) {
12409 diff = (int)((t - f) + 1);
12410 total_glyphs += diff;
12412 return total_glyphs;
12415nk_font_default_glyph_ranges(
void)
12421nk_font_chinese_glyph_ranges(
void)
12434nk_font_cyrillic_glyph_ranges(
void)
12446nk_font_korean_glyph_ranges(
void)
12457nk_font_baker_memory(
nk_size *temp,
int *glyph_count,
12458 struct nk_font_config *config_list,
int count)
12460 int range_count = 0;
12461 int total_range_count = 0;
12462 struct nk_font_config *iter, *i;
12464 NK_ASSERT(config_list);
12465 NK_ASSERT(glyph_count);
12466 if (!config_list) {
12472 for (iter = config_list; iter; iter = iter->next) {
12474 do {
if (!i->range) iter->range = nk_font_default_glyph_ranges();
12475 range_count = nk_range_count(i->range);
12476 total_range_count += range_count;
12477 *glyph_count += nk_range_glyph_count(i->range, range_count);
12478 }
while ((i = i->n) != iter);
12480 *temp = (
nk_size)*glyph_count *
sizeof(
struct nk_rp_rect);
12481 *temp += (
nk_size)total_range_count *
sizeof(
struct nk_tt_pack_range);
12482 *temp += (
nk_size)*glyph_count *
sizeof(
struct nk_tt_packedchar);
12483 *temp += (
nk_size)count *
sizeof(
struct nk_font_bake_data);
12484 *temp +=
sizeof(
struct nk_font_baker);
12485 *temp += nk_rect_align + nk_range_align + nk_char_align;
12486 *temp += nk_build_align + nk_baker_align;
12489nk_font_baker(
void *memory,
int glyph_count,
int count,
struct nk_allocator *alloc)
12491 struct nk_font_baker *baker;
12492 if (!memory)
return 0;
12494 baker = (
struct nk_font_baker*)
NK_ALIGN_PTR(memory, nk_baker_align);
12495 baker->build = (
struct nk_font_bake_data*)
NK_ALIGN_PTR((baker + 1), nk_build_align);
12496 baker->packed_chars = (
struct nk_tt_packedchar*)
NK_ALIGN_PTR((baker->build + count), nk_char_align);
12497 baker->rects = (
struct nk_rp_rect*)
NK_ALIGN_PTR((baker->packed_chars + glyph_count), nk_rect_align);
12498 baker->ranges = (
struct nk_tt_pack_range*)
NK_ALIGN_PTR((baker->rects + glyph_count), nk_range_align);
12499 baker->alloc = *alloc;
12503nk_font_bake_pack(
struct nk_font_baker *baker,
12504 nk_size *image_memory,
int *width,
int *height,
struct nk_recti *custom,
12505 const struct nk_font_config *config_list,
int count,
12509 const struct nk_font_config *config_iter, *it;
12510 int total_glyph_count = 0;
12511 int total_range_count = 0;
12512 int range_count = 0;
12515 NK_ASSERT(image_memory);
12518 NK_ASSERT(config_list);
12522 if (!image_memory || !width || !height || !config_list || !count)
return nk_false;
12523 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
12525 do {range_count = nk_range_count(it->range);
12526 total_range_count += range_count;
12527 total_glyph_count += nk_range_glyph_count(it->range, range_count);
12528 }
while ((it = it->n) != config_iter);
12531 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
12533 do {
if (!nk_tt_InitFont(&baker->build[i++].info, (
const unsigned char*)it->ttf_blob, 0))
12535 }
while ((it = it->n) != config_iter);
12538 *width = (total_glyph_count > 1000) ? 1024 : 512;
12539 nk_tt_PackBegin(&baker->spc, 0, (
int)*width, (
int)max_height, 0, 1, alloc);
12548 struct nk_rp_rect custom_space;
12549 nk_zero(&custom_space,
sizeof(custom_space));
12550 custom_space.w = (nk_rp_coord)(custom->
w);
12551 custom_space.h = (nk_rp_coord)(custom->
h);
12553 nk_tt_PackSetOversampling(&baker->spc, 1, 1);
12554 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, &custom_space, 1);
12555 *height =
NK_MAX(*height, (
int)(custom_space.y + custom_space.h));
12557 custom->
x = (short)custom_space.x;
12558 custom->
y = (
short)custom_space.y;
12559 custom->
w = (short)custom_space.w;
12560 custom->
h = (
short)custom_space.h;
12564 for (input_i = 0, config_iter = config_list; input_i < count && config_iter;
12565 config_iter = config_iter->next) {
12570 const struct nk_font_config *cfg = it;
12571 struct nk_font_bake_data *tmp = &baker->build[input_i++];
12574 glyph_count = 0; range_count = 0;
12575 for (in_range = cfg->range; in_range[0] && in_range[1]; in_range += 2) {
12576 glyph_count += (int)(in_range[1] - in_range[0]) + 1;
12581 tmp->ranges = baker->ranges + range_n;
12582 tmp->range_count = (
nk_rune)range_count;
12583 range_n += range_count;
12584 for (i = 0; i < range_count; ++i) {
12585 in_range = &cfg->range[i * 2];
12586 tmp->ranges[i].font_size = cfg->size;
12587 tmp->ranges[i].first_unicode_codepoint_in_range = (int)in_range[0];
12588 tmp->ranges[i].num_chars = (int)(in_range[1]- in_range[0]) + 1;
12589 tmp->ranges[i].chardata_for_range = baker->packed_chars + char_n;
12590 char_n += tmp->ranges[i].num_chars;
12594 tmp->rects = baker->rects + rect_n;
12595 rect_n += glyph_count;
12596 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
12597 n = nk_tt_PackFontRangesGatherRects(&baker->spc, &tmp->info,
12598 tmp->ranges, (
int)tmp->range_count, tmp->rects);
12599 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, tmp->rects, (
int)n);
12602 for (i = 0; i < n; ++i) {
12603 if (tmp->rects[i].was_packed)
12604 *height =
NK_MAX(*height, tmp->rects[i].y + tmp->rects[i].h);
12606 }
while ((it = it->n) != config_iter);
12608 NK_ASSERT(rect_n == total_glyph_count);
12609 NK_ASSERT(char_n == total_glyph_count);
12610 NK_ASSERT(range_n == total_range_count);
12612 *height = (int)nk_round_up_pow2((
nk_uint)*height);
12617nk_font_bake(
struct nk_font_baker *baker,
void *image_memory,
int width,
int height,
12618 struct nk_font_glyph *glyphs,
int glyphs_count,
12619 const struct nk_font_config *config_list,
int font_count)
12623 const struct nk_font_config *config_iter;
12624 const struct nk_font_config *it;
12626 NK_ASSERT(image_memory);
12629 NK_ASSERT(config_list);
12631 NK_ASSERT(font_count);
12632 NK_ASSERT(glyphs_count);
12633 if (!image_memory || !width || !height || !config_list ||
12634 !font_count || !glyphs || !glyphs_count)
12639 baker->spc.pixels = (
unsigned char*)image_memory;
12640 baker->spc.height = (int)height;
12641 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
12642 config_iter = config_iter->next) {
12644 do {
const struct nk_font_config *cfg = it;
12645 struct nk_font_bake_data *tmp = &baker->build[input_i++];
12646 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
12647 nk_tt_PackFontRangesRenderIntoRects(&baker->spc, &tmp->info, tmp->ranges,
12648 (
int)tmp->range_count, tmp->rects, &baker->alloc);
12649 }
while ((it = it->n) != config_iter);
12650 } nk_tt_PackEnd(&baker->spc, &baker->alloc);
12653 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
12654 config_iter = config_iter->next) {
12659 const struct nk_font_config *cfg = it;
12660 struct nk_font_bake_data *tmp = &baker->build[input_i++];
12661 struct nk_baked_font *dst_font = cfg->font;
12663 float font_scale = nk_tt_ScaleForPixelHeight(&tmp->info, cfg->size);
12664 int unscaled_ascent, unscaled_descent, unscaled_line_gap;
12665 nk_tt_GetFontVMetrics(&tmp->info, &unscaled_ascent, &unscaled_descent,
12666 &unscaled_line_gap);
12669 if (!cfg->merge_mode) {
12670 dst_font->ranges = cfg->range;
12671 dst_font->height = cfg->size;
12672 dst_font->ascent = ((float)unscaled_ascent * font_scale);
12673 dst_font->descent = ((float)unscaled_descent * font_scale);
12674 dst_font->glyph_offset = glyph_n;
12677 dst_font->glyph_count = 0;
12681 for (i = 0; i < tmp->range_count; ++i) {
12682 struct nk_tt_pack_range *range = &tmp->ranges[i];
12683 for (char_idx = 0; char_idx < range->num_chars; char_idx++)
12686 float dummy_x = 0, dummy_y = 0;
12687 struct nk_tt_aligned_quad q;
12688 struct nk_font_glyph *glyph;
12691 const struct nk_tt_packedchar *pc = &range->chardata_for_range[char_idx];
12692 if (!pc->x0 && !pc->x1 && !pc->y0 && !pc->y1)
continue;
12693 codepoint = (
nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
12694 nk_tt_GetPackedQuad(range->chardata_for_range, (
int)width,
12695 (
int)height, char_idx, &dummy_x, &dummy_y, &q, 0);
12698 glyph = &glyphs[dst_font->glyph_offset + dst_font->glyph_count + (
unsigned int)glyph_count];
12699 glyph->codepoint = codepoint;
12700 glyph->x0 = q.x0; glyph->y0 = q.y0;
12701 glyph->x1 = q.x1; glyph->y1 = q.y1;
12702 glyph->y0 += (dst_font->ascent + 0.5f);
12703 glyph->y1 += (dst_font->ascent + 0.5f);
12704 glyph->w = glyph->x1 - glyph->x0 + 0.5f;
12705 glyph->h = glyph->y1 - glyph->y0;
12707 if (cfg->coord_type == NK_COORD_PIXEL) {
12708 glyph->u0 = q.s0 * (float)width;
12709 glyph->v0 = q.t0 * (float)height;
12710 glyph->u1 = q.s1 * (float)width;
12711 glyph->v1 = q.t1 * (float)height;
12718 glyph->xadvance = (pc->xadvance + cfg->spacing.x);
12719 if (cfg->pixel_snap)
12720 glyph->xadvance = (float)(
int)(glyph->xadvance + 0.5f);
12724 dst_font->glyph_count += glyph_count;
12725 glyph_n += glyph_count;
12726 }
while ((it = it->n) != config_iter);
12730nk_font_bake_custom_data(
void *img_memory,
int img_width,
int img_height,
12731 struct nk_recti img_dst,
const char *texture_data_mask,
int tex_width,
12732 int tex_height,
char white,
char black)
12739 NK_ASSERT(img_memory);
12740 NK_ASSERT(img_width);
12741 NK_ASSERT(img_height);
12742 NK_ASSERT(texture_data_mask);
12744 if (!img_memory || !img_width || !img_height || !texture_data_mask)
12747 pixels = (
nk_byte*)img_memory;
12748 for (y = 0, n = 0; y < tex_height; ++y) {
12749 for (x = 0; x < tex_width; ++x, ++n) {
12750 const int off0 = ((img_dst.
x + x) + (img_dst.
y + y) * img_width);
12751 const int off1 = off0 + 1 + tex_width;
12752 pixels[off0] = (texture_data_mask[n] == white) ? 0xFF : 0x00;
12753 pixels[off1] = (texture_data_mask[n] == black) ? 0xFF : 0x00;
12758nk_font_bake_convert(
void *out_memory,
int img_width,
int img_height,
12759 const void *in_memory)
12765 NK_ASSERT(out_memory);
12766 NK_ASSERT(in_memory);
12767 NK_ASSERT(img_width);
12768 NK_ASSERT(img_height);
12769 if (!out_memory || !in_memory || !img_height || !img_width)
return;
12772 src = (
const nk_byte*)in_memory;
12773 for (n = (
int)(img_width * img_height); n > 0; n--)
12774 *dst++ = ((
nk_rune)(*src++) << 24) | 0x00FFFFFF;
12783nk_font_text_width(
nk_handle handle,
float height,
const char *text,
int len)
12787 float text_width = 0;
12791 struct nk_font *font = (
struct nk_font*)handle.
ptr;
12793 NK_ASSERT(font->glyphs);
12794 if (!font || !text || !len)
12797 scale = height/font->info.height;
12798 glyph_len = text_len =
nk_utf_decode(text, &unicode, (
int)len);
12799 if (!glyph_len)
return 0;
12800 while (text_len <= (
int)len && glyph_len) {
12801 const struct nk_font_glyph *g;
12805 g = nk_font_find_glyph(font, unicode);
12806 text_width += g->xadvance * scale;
12809 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)len - text_len);
12810 text_len += glyph_len;
12814#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
12816nk_font_query_font_glyph(
nk_handle handle,
float height,
12817 struct nk_user_font_glyph *glyph,
nk_rune codepoint,
nk_rune next_codepoint)
12820 const struct nk_font_glyph *g;
12821 struct nk_font *font;
12826 font = (
struct nk_font*)handle.
ptr;
12828 NK_ASSERT(font->glyphs);
12829 if (!font || !glyph)
12832 scale = height/font->info.height;
12833 g = nk_font_find_glyph(font, codepoint);
12834 glyph->width = (g->x1 - g->x0) * scale;
12835 glyph->height = (g->y1 - g->y0) * scale;
12836 glyph->offset =
nk_vec2(g->x0 * scale, g->y0 * scale);
12837 glyph->xadvance = (g->xadvance * scale);
12838 glyph->uv[0] =
nk_vec2(g->u0, g->v0);
12839 glyph->uv[1] =
nk_vec2(g->u1, g->v1);
12842NK_API const struct nk_font_glyph*
12843nk_font_find_glyph(
struct nk_font *font,
nk_rune unicode)
12847 int total_glyphs = 0;
12848 const struct nk_font_glyph *glyph = 0;
12849 const struct nk_font_config *iter = 0;
12852 NK_ASSERT(font->glyphs);
12853 NK_ASSERT(font->info.ranges);
12854 if (!font || !font->glyphs)
return 0;
12856 glyph = font->fallback;
12857 iter = font->config;
12858 do {count = nk_range_count(iter->range);
12859 for (i = 0; i < count; ++i) {
12860 nk_rune f = iter->range[(i*2)+0];
12861 nk_rune t = iter->range[(i*2)+1];
12862 int diff = (int)((t - f) + 1);
12863 if (unicode >= f && unicode <= t)
12864 return &font->glyphs[((
nk_rune)total_glyphs + (unicode - f))];
12865 total_glyphs += diff;
12867 }
while ((iter = iter->n) != font->config);
12871nk_font_init(
struct nk_font *font,
float pixel_height,
12872 nk_rune fallback_codepoint,
struct nk_font_glyph *glyphs,
12873 const struct nk_baked_font *baked_font,
nk_handle atlas)
12875 struct nk_baked_font baked;
12878 NK_ASSERT(baked_font);
12879 if (!font || !glyphs || !baked_font)
12882 baked = *baked_font;
12883 font->fallback = 0;
12884 font->info = baked;
12885 font->scale = (float)pixel_height / (
float)font->info.height;
12886 font->glyphs = &glyphs[baked_font->glyph_offset];
12887 font->texture = atlas;
12888 font->fallback_codepoint = fallback_codepoint;
12889 font->fallback = nk_font_find_glyph(font, fallback_codepoint);
12891 font->handle.height = font->info.height * font->scale;
12892 font->handle.width = nk_font_text_width;
12893 font->handle.userdata.ptr = font;
12894#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
12895 font->handle.query = nk_font_query_font_glyph;
12896 font->handle.texture = font->texture;
12910#pragma clang diagnostic push
12911#pragma clang diagnostic ignored "-Woverlength-strings"
12912#elif defined(__GNUC__) || defined(__GNUG__)
12913#pragma GCC diagnostic push
12914#pragma GCC diagnostic ignored "-Woverlength-strings"
12917#ifdef NK_INCLUDE_DEFAULT_FONT
12919NK_GLOBAL const char nk_proggy_clean_ttf_compressed_data_base85[11980+1] =
12920 "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
12921 "2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
12922 "`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
12923 "i@^rMl9t=cWq6##weg>$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;-<nLENhvx>-VsM.M0rJfLH2eTM`*oJMHRC`N"
12924 "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa<XCMKEV*N)LN/N"
12925 "*b=%Q6pia-Xg8I$<MR&,VdJe$<(7G;Ckl'&hF;;$<_=X(b.RS%%)###MPBuuE1V:v&cXm#(&cV]`k9OhLMbn%s$G2,B$BfD3X*sp5#l,$R#]x_X1xKX%b5U*[r5iMfUo9U`N99hG)"
12926 "tm+/Us9pG)XPu`<0s-)WTt(gCRxIg(%6sfh=ktMKn3j)<6<b5Sk_/0(^]AaN#(p/L>&VZ>1i%h1S9u5o@YaaW$e+b<TWFn/Z:Oh(Cx2$lNEoN^e)#CFY@@I;BOQ*sRwZtZxRcU7uW6CX"
12927 "ow0i(?$Q[cjOd[P4d)]>ROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc."
12928 "x]Ip.PH^'/aqUO/$1WxLoW0[iLA<QT;5HKD+@qQ'NQ(3_PLhE48R.qAPSwQ0/WK?Z,[x?-J;jQTWA0X@KJ(_Y8N-:/M74:/-ZpKrUss?d#dZq]DAbkU*JqkL+nwX@@47`5>w=4h(9.`G"
12929 "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?G<Nald$qs]@]L<J7bR*>gv:[7MI2k).'2($5FNP&EQ(,)"
12930 "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#"
12931 "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM"
12932 "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0<q-]L_?^)1vw'.,MRsqVr.L;aN&#/EgJ)PBc[-f>+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu"
12933 "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/"
12934 "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[K<L"
12935 "%a2E-grWVM3@2=-k22tL]4$##6We'8UJCKE[d_=%wI;'6X-GsLX4j^SgJ$##R*w,vP3wK#iiW&#*h^D&R?jp7+/u&#(AP##XU8c$fSYW-J95_-Dp[g9wcO&#M-h1OcJlc-*vpw0xUX&#"
12936 "OQFKNX@QI'IoPp7nb,QU//MQ&ZDkKP)X<WSVL(68uVl&#c'[0#(s1X&xm$Y%B7*K:eDA323j998GXbA#pwMs-jgD$9QISB-A_(aN4xoFM^@C58D0+Q+q3n0#3U1InDjF682-SjMXJK)("
12937 "h$hxua_K]ul92%'BOU&#BRRh-slg8KDlr:%L71Ka:.A;%YULjDPmL<LYs8i#XwJOYaKPKc1h:'9Ke,g)b),78=I39B;xiY$bgGw-&.Zi9InXDuYa%G*f2Bq7mn9^#p1vv%#(Wi-;/Z5h"
12938 "o;#2:;%d	v68C5g?ntX0X)pT`;%pB3q7mgGN)3%(P8nTd5L7GeA-GL@+%J3u2:(Yf>et`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO"
12939 "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J<j$UpK<Q4a1]MupW^-"
12940 "sj_$%[HK%'F####QRZJ::Y3EGl4'@%FkiAOg#p[##O`gukTfBHagL<LHw%q&OV0##F=6/:chIm0@eCP8X]:kFI%hl8hgO@RcBhS-@Qb$%+m=hPDLg*%K8ln(wcf3/'DW-$.lR?n[nCH-"
12941 "eXOONTJlh:.RYF%3'p6sq:UIMA945&^HFS87@$EP2iG<-lCO$%c`uKGD3rC$x0BL8aFn--`ke%#HMP'vh1/R&O_J9'um,.<tx[@%wsJk&bUT2`0uMv7gg#qp/ij.L56'hl;.s5CUrxjO"
12942 "M7-##.l+Au'A&O:-T72L]P`&=;ctp'XScX*rU.>-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%"
12943 "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$M<Jnq79VsJW/mWS*PUiq76;]/NM_>hLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]"
12944 "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et"
12945 "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$<M-SGZ':+Q_k+uvOSLiEo(<aD/K<CCc`'Lx>'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:"
12946 "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VB<HFF*qL("
12947 "$/V,;(kXZejWO`<[5?\?ewY(*9=%wDc;,u<'9t3W-(H1th3+G]ucQ]kLs7df($/*JL]@*t7Bu_G3_7mp7<iaQjO@.kLg;x3B0lqp7Hf,^Ze7-##@/c58Mo(3;knp0%)A7?-W+eI'o8)b<"
12948 "nKnw'Ho8C=Y>pqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<<aG/1N$#FX$0V5Y6x'aErI3I$7x%E`v<-BY,)%-?Psf*l?%C3.mM(=/M0:JxG'?"
12949 "7WhH%o'a<-80g0NBxoO(GH<dM]n.+%q@jH?f.UsJ2Ggs&4<-e47&Kl+f//9@`b+?.TeN_&B8Ss?v;^Trk;f#YvJkl&w$]>-+k?'(<S:68tq*WoDfZu';mM?8X[ma8W%*`-=;D.(nc7/;"
12950 ")g:T1=^J$&BRV(-lTmNB6xqB[@0*o.erM*<SWF]u2=st-*(6v>^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M"
12951 "D?@f&1'BW-)Ju<L25gl8uhVm1hL$##*8###'A3/LkKW+(^rWX?5W_8g)a(m&K8P>#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX("
12952 "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs"
12953 "bIu)'Z,*[>br5fX^:FPAWr-m2KgL<LUN098kTF&#lvo58=/vjDo;.;)Ka*hLR#/k=rKbxuV`>Q_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q"
12954 "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aeg<Z'<$#4H)6,>e0jT6'N#(q%.O=?2S]u*(m<-"
12955 "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i"
12956 "sZ88+dKQ)W6>J%CL<KE>`.d*(B`-n8D9oK<Up]c$X$(,)M8Zt7/[rdkqTgl-0cuGMv'?>-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P	r+$%CE=68>K8r0=dSC%%(@p7"
12957 ".m7jilQ02'0-VWAg<a/''3u.=4L$Y)6k/K:_[3=&jvL<L0C/2'v:^;-DIBW,B4E68:kZ;%?8(Q8BH=kO65BW?xSG&#@uU,DS*,?.+(o(#1vCS8#CHF>TlGW'b)Tq7VT9q^*^$$.:&N@@"
12958 "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*"
12959 "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u"
12960 "@-W$U%VEQ/,,>>#)D<h#`)h0:<Q6909ua+&VU%n2:cG3FJ-%@Bj-DgLr`Hw&HAKjKjseK</xKT*)B,N9X3]krc12t'pgTV(Lv-tL[xg_%=M_q7a^x?7Ubd>#%8cY#YZ?=,`Wdxu/ae&#"
12961 "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$s<Eh#c&)q.MXI%#v9ROa5FZO%sF7q7Nwb&#ptUJ:aqJe$Sl68%.D###EC><?-aF&#RNQv>o8lKN%5/$(vdfq7+ebA#"
12962 "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(<c`Q8N)jEIF*+?P2a8g%)$q]o2aH8C&<SibC/q,(e:v;-b#6[$NtDZ84Je2KNvB#$P5?tQ3nt(0"
12963 "d=j.LQf./Ll33+(;q3L-w=8dX$#WF&uIJ@-bfI>%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8"
12964 "6e%B/:=>)N4xeW.*wft-;$'58-ESqr<b?UI(_%@[P46>#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#"
12965 "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjL<Lni;''X.`$#8+1GD"
12966 ":k$YUWsbn8ogh6rxZ2Z9]%nd+>V#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#<NEdtg(n'=S1A(Q1/I&4([%dM`,Iu'1:_hL>SfD07&6D<fp8dHM7/g+"
12967 "tlPN9J*rKaPct&?'uBCem^jn%9_K)<,C5K3s=5g&GmJb*[SYq7K;TRLGCsM-$$;S%:Y@r7AK0pprpL<Lrh,q7e/%KWK:50I^+m'vi`3?%Zp+<-d+$L-Sv:@.o19n$s0&39;kn;S%BSq*"
12968 "$3WoJSCLweV[aZ'MQIjO<7;X-X;&+dMLvu#^UsGEC9WEc[X(wI7#2.(F0jV*eZf<-Qv3J-c+J5AlrB#$p(H68LvEA'q3n0#m,[`*8Ft)FcYgEud]CWfm68,(aLA$@EFTgLXoBq/UPlp7"
12969 ":d[/;r_ix=:TF`S5H-b<LI&HY(K=h#)]Lk$K14lVfm:x$H<3^Ql<M`$OhapBnkup'D#L$Pb_`N*g]2e;X/Dtg,bsj&K#2[-:iYr'_wgH)NUIR8a1n#S?Yej'h8^58UbZd+^FKD*T@;6A"
12970 "7aQC[K8d-(v6GI$x:T<&'Gp5Uf>@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-<aN((^7('#Z0wK#5GX@7"
12971 "u][`*S^43933A4rl][`*O4CgLEl]v$1Q3AeF37dbXk,.)vj#x'd`;qgbQR%FW,2(?LO=s%Sc68%NP'##Aotl8x=BE#j1UD([3$M(]UI2LX3RpKN@;/#f'f/&_mt&F)XdF<9t4)Qa.*kT"
12972 "LwQ'(TTB9.xH'>#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5<N?)NBS)QN*_I,?&)2'IM%L3I)X((e/dl2&8'<M"
12973 ":^#M*Q+[T.Xri.LYS3v%fF`68h;b-X[/En'CR.q7E)p'/kle2HM,u;^%OKC-N+Ll%F9CF<Nf'^#t2L,;27W:0O@6##U6W7:$rJfLWHj$#)woqBefIZ.PK<b*t7ed;p*_m;4ExK#h@&]>"
12974 "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%"
12975 "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;"
12976 "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmL<LD)F^%[tC'8;+9E#C$g%#5Y>q9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:"
12977 "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3<n-&%H%b<FDj2M<hH=&Eh<2Len$b*aTX=-8QxN)k11IM1c^j%"
12978 "9s<L<NFSo)B?+<-(GxsF,^-Eh@$4dXhN$+#rxK8'je'D7k`e;)2pYwPA'_p9&@^18ml1^[@g4t*[JOa*[=Qp7(qJ_oOL^('7fB&Hq-:sf,sNj8xq^>$U4O]GKx'm9)b@p7YsvK3w^YR-"
12979 "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*"
12980 "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdF<TddF<9Ah-6&9tWoDlh]&1SpGMq>Ti1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IX<N+T+0MlMBPQ*Vj>SsD<U4JHY"
12981 "8kD2)2fU/M#$e.)T4,_=8hLim[&);?UkK'-x?'(:siIfL<$pFM`i<?%W(mGDHM%>iWP,##P`%/L<eXi:@Z9C.7o=@(pXdAO/NLQ8lPl+HPOQa8wD8=^GlPa8TKI1CjhsCTSLJM'/Wl>-"
12982 "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n<bhPmUkMw>%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL<LoNs'6,'85`"
12983 "0?t/'_U59@]ddF<#LdF<eWdF<OuN/45rY<-L@&#+fm>69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdF<gR@2L=FNU-<b[(9c/ML3m;Z[$oF3g)GAWqpARc=<ROu7cL5l;-[A]%/"
12984 "+fsd;l#SafT/f*W]0=O'$(Tb<[)*@e775R-:Yob%g*>l*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj"
12985 "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#<IGe;__.thjZl<%w(Wk2xmp4Q@I#I9,DF]u7-P=.-_:YJ]aS@V"
12986 "?6*C()dOp7:WL,b&3Rg/.cmM9&r^>$(>.Z-I&J(Q0Hd5Q%7Co-b`-c<N(6r@ip+AurK<m86QIth*#v;-OBqi+L7wDE-Ir8K['m+DDSLwK&/.?-V%U_%3:qKNu$_b*B-kp7NaD'QdWQPK"
12987 "Yq[@>P)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8<FfNkgg^oIbah*#8/Qt$F&:K*-(N/'+1vMB,u()-a.VUU*#[e%gAAO(S>WlA2);Sa"
12988 ">gXm8YB`1d@K#n]76-a$U,mF<fX]idqd)<3,]J7JmW4`6]uks=4-72L(jEk+:bJ0M^q-8Dm_Z?0olP1C9Sa&H[d&c$ooQUj]Exd*3ZM@-WGW2%s',B-_M%>%Ul:#/'xoFM9QX-$.QN'>"
12989 "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B</R90;eZ]%Ncq;-Tl]#F>2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I"
12990 "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1<Vc52=u`3^o-n1'g4v58Hj&6_t7$##?M)c<$bgQ_'SY((-xkA#"
12991 "Y(,p'H9rIVY-b,'%bCPF7.J<Up^,(dU1VY*5#WkTU>h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-u<Hp,3@e^9UB1J+ak9-TN/mhKPg+AJYd$"
12992 "MlvAF_jCK*.O-^(63adMT->W%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)"
12993 "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo"
12994 "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P"
12995 "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*<h`e-GI7)?OK2A.d7_c)?wQ5AS@DL3r#7fSkgl6-++D:'A,uq7SvlB$pcpH'q3n0#_%dY#xCpr-l<F0NR@-##FEV6NTF6##$l84N1w?AO>'IAO"
12996 "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#"
12997 ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T<XoIB&hx=T1PcDaB&;HH+-AFr?(m9HZV)FKS8JCw;SD=6[^/DZUL`EUDf]GGlG&>"
12998 "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#<xU?#@.i?#D:%@#HF7@#LRI@#P_[@#Tkn@#Xw*A#]-=A#a9OA#"
12999 "d<F&#*;G##.GY##2Sl##6`($#:l:$#>xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4"
13000 "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#"
13001 "/QHC#3^ZC#7jmC#;v)D#?,<D#C8ND#GDaD#KPsD#O]/E#g1A5#KA*1#gC17#MGd;#8(02#L-d3#rWM4#Hga1#,<w0#T.j<#O#'2#CYN1#qa^:#_4m3#o@/=#eG8=#t8J5#`+78#4uI-#"
13002 "m3B2#SB[8#Q0@8#i[*9#iOn8#1Nm;#^sN9#qh<9#:=x-#P;K2#$%X9#bC+.#Rg;<#mN=.#MTF.#RZO.#2?)4#Y#(/#[)1/#b;L/#dAU/#0Sv;#lY$0#n`-0#sf60#(F24#wrH0#%/e0#"
13003 "TmD<#%JSMFove:CTBEXI:<eh2g)B,3h2^G3i;#d3jD>)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP"
13004 "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
13005 "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
13009#define NK_CURSOR_DATA_W 90
13010#define NK_CURSOR_DATA_H 27
13011NK_GLOBAL const char nk_custom_cursor_data[NK_CURSOR_DATA_W * NK_CURSOR_DATA_H + 1] =
13013 "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX"
13014 "..- -X.....X- X.X - X.X -X.....X - X.....X"
13015 "--- -XXX.XXX- X...X - X...X -X....X - X....X"
13016 "X - X.X - X.....X - X.....X -X...X - X...X"
13017 "XX - X.X -X.......X- X.......X -X..X.X - X.X..X"
13018 "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X"
13019 "X..X - X.X - X.X - X.X -XX X.X - X.X XX"
13020 "X...X - X.X - X.X - XX X.X XX - X.X - X.X "
13021 "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X "
13022 "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X "
13023 "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X "
13024 "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X "
13025 "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X "
13026 "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X "
13027 "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X "
13028 "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X "
13029 "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX "
13030 "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------"
13031 "X.X X..X - -X.......X- X.......X - XX XX - "
13032 "XX X..X - - X.....X - X.....X - X.X X.X - "
13033 " X..X - X...X - X...X - X..X X..X - "
13034 " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - "
13035 "------------ - X - X -X.....................X- "
13036 " ----------------------------------- X...XXXXXXXXXXXXX...X - "
13043#pragma clang diagnostic pop
13044#elif defined(__GNUC__) || defined(__GNUG__)
13045#pragma GCC diagnostic pop
13055nk_decompress_length(
unsigned char *input)
13057 return (
unsigned int)((input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]);
13060nk__match(
unsigned char *data,
unsigned int length)
13063 NK_ASSERT (nk__dout + length <= nk__barrier);
13064 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
13065 if (data < nk__barrier4) { nk__dout = nk__barrier+1;
return; }
13066 while (length--) *nk__dout++ = *data++;
13069nk__lit(
unsigned char *data,
unsigned int length)
13071 NK_ASSERT (nk__dout + length <= nk__barrier);
13072 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
13073 if (data < nk__barrier2) { nk__dout = nk__barrier+1;
return; }
13074 NK_MEMCPY(nk__dout, data, length);
13075 nk__dout += length;
13078nk_decompress_token(
unsigned char *i)
13080 #define nk__in2(x) ((i[x] << 8) + i[(x)+1])
13081 #define nk__in3(x) ((i[x] << 16) + nk__in2((x)+1))
13082 #define nk__in4(x) ((i[x] << 24) + nk__in3((x)+1))
13085 if (*i >= 0x80) nk__match(nk__dout-i[1]-1, (
unsigned int)i[0] - 0x80 + 1), i += 2;
13086 else if (*i >= 0x40) nk__match(nk__dout-(nk__in2(0) - 0x4000 + 1), (
unsigned int)i[2]+1), i += 3;
13087 else nk__lit(i+1, (
unsigned int)i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
13089 if (*i >= 0x18) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x180000 + 1), (
unsigned int)i[3]+1), i += 4;
13090 else if (*i >= 0x10) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x100000 + 1), (
unsigned int)nk__in2(3)+1), i += 5;
13091 else if (*i >= 0x08) nk__lit(i+2, (
unsigned int)nk__in2(0) - 0x0800 + 1), i += 2 + (nk__in2(0) - 0x0800 + 1);
13092 else if (*i == 0x07) nk__lit(i+3, (
unsigned int)nk__in2(1) + 1), i += 3 + (nk__in2(1) + 1);
13093 else if (*i == 0x06) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), i[4]+1u), i += 5;
13094 else if (*i == 0x04) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), (
unsigned int)nk__in2(4)+1u), i += 6;
13099nk_adler32(
unsigned int adler32,
unsigned char *buffer,
unsigned int buflen)
13101 const unsigned long ADLER_MOD = 65521;
13102 unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
13103 unsigned long blocklen, i;
13105 blocklen = buflen % 5552;
13107 for (i=0; i + 7 < blocklen; i += 8) {
13108 s1 += buffer[0]; s2 += s1;
13109 s1 += buffer[1]; s2 += s1;
13110 s1 += buffer[2]; s2 += s1;
13111 s1 += buffer[3]; s2 += s1;
13112 s1 += buffer[4]; s2 += s1;
13113 s1 += buffer[5]; s2 += s1;
13114 s1 += buffer[6]; s2 += s1;
13115 s1 += buffer[7]; s2 += s1;
13118 for (; i < blocklen; ++i) {
13119 s1 += *buffer++; s2 += s1;
13122 s1 %= ADLER_MOD; s2 %= ADLER_MOD;
13123 buflen -= (
unsigned int)blocklen;
13126 return (
unsigned int)(s2 << 16) + (
unsigned int)s1;
13129nk_decompress(
unsigned char *output,
unsigned char *i,
unsigned int length)
13132 if (nk__in4(0) != 0x57bC0000)
return 0;
13133 if (nk__in4(4) != 0)
return 0;
13134 olen = nk_decompress_length(i);
13136 nk__barrier3 = i+length;
13137 nk__barrier = output + olen;
13138 nk__barrier4 = output;
13143 unsigned char *old_i = i;
13144 i = nk_decompress_token(i);
13146 if (*i == 0x05 && i[1] == 0xfa) {
13147 NK_ASSERT(nk__dout == output + olen);
13148 if (nk__dout != output + olen)
return 0;
13149 if (nk_adler32(1, output, olen) != (
unsigned int) nk__in4(2))
13157 NK_ASSERT(nk__dout <= output + olen);
13158 if (nk__dout > output + olen)
13163nk_decode_85_byte(
char c)
13165 return (
unsigned int)((c >=
'\\') ? c-36 : c-35);
13168nk_decode_85(
unsigned char* dst,
const unsigned char* src)
13173 nk_decode_85_byte((
char)src[0]) +
13174 85 * (nk_decode_85_byte((
char)src[1]) +
13175 85 * (nk_decode_85_byte((
char)src[2]) +
13176 85 * (nk_decode_85_byte((
char)src[3]) +
13177 85 * nk_decode_85_byte((
char)src[4]))));
13180 dst[0] = (
unsigned char)((tmp >> 0) & 0xFF);
13181 dst[1] = (
unsigned char)((tmp >> 8) & 0xFF);
13182 dst[2] = (
unsigned char)((tmp >> 16) & 0xFF);
13183 dst[3] = (
unsigned char)((tmp >> 24) & 0xFF);
13195NK_API struct nk_font_config
13196nk_font_config(float pixel_height)
13198 struct nk_font_config cfg;
13202 cfg.ttf_data_owned_by_atlas = 0;
13203 cfg.size = pixel_height;
13204 cfg.oversample_h = 3;
13205 cfg.oversample_v = 1;
13206 cfg.pixel_snap = 0;
13207 cfg.coord_type = NK_COORD_UV;
13209 cfg.range = nk_font_default_glyph_ranges();
13210 cfg.merge_mode = 0;
13211 cfg.fallback_glyph =
'?';
13216#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
13218nk_font_atlas_init_default(
struct nk_font_atlas *atlas)
13221 if (!atlas)
return;
13223 atlas->temporary.userdata.ptr = 0;
13224 atlas->temporary.alloc = nk_malloc;
13225 atlas->temporary.free = nk_mfree;
13226 atlas->permanent.userdata.ptr = 0;
13227 atlas->permanent.alloc = nk_malloc;
13228 atlas->permanent.free = nk_mfree;
13232nk_font_atlas_init(
struct nk_font_atlas *atlas,
struct nk_allocator *alloc)
13236 if (!atlas || !alloc)
return;
13238 atlas->permanent = *alloc;
13239 atlas->temporary = *alloc;
13242nk_font_atlas_init_custom(
struct nk_font_atlas *atlas,
13246 NK_ASSERT(permanent);
13247 NK_ASSERT(temporary);
13248 if (!atlas || !permanent || !temporary)
return;
13250 atlas->permanent = *permanent;
13251 atlas->temporary = *temporary;
13254nk_font_atlas_begin(
struct nk_font_atlas *atlas)
13257 NK_ASSERT(atlas->temporary.alloc && atlas->temporary.free);
13258 NK_ASSERT(atlas->permanent.alloc && atlas->permanent.free);
13259 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free ||
13260 !atlas->temporary.alloc || !atlas->temporary.free)
return;
13261 if (atlas->glyphs) {
13262 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
13265 if (atlas->pixel) {
13266 atlas->permanent.free(atlas->permanent.userdata, atlas->pixel);
13271nk_font_atlas_add(
struct nk_font_atlas *atlas,
const struct nk_font_config *config)
13273 struct nk_font *font = 0;
13274 struct nk_font_config *cfg;
13277 NK_ASSERT(atlas->permanent.alloc);
13278 NK_ASSERT(atlas->permanent.free);
13279 NK_ASSERT(atlas->temporary.alloc);
13280 NK_ASSERT(atlas->temporary.free);
13283 NK_ASSERT(config->ttf_blob);
13284 NK_ASSERT(config->ttf_size);
13285 NK_ASSERT(config->size > 0.0f);
13287 if (!atlas || !config || !config->ttf_blob || !config->ttf_size || config->size <= 0.0f||
13288 !atlas->permanent.alloc || !atlas->permanent.free ||
13289 !atlas->temporary.alloc || !atlas->temporary.free)
13293 cfg = (
struct nk_font_config*)
13294 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font_config));
13295 NK_MEMCPY(cfg, config,
sizeof(*config));
13299 if (!config->merge_mode) {
13301 if (!atlas->config) {
13302 atlas->config = cfg;
13305 struct nk_font_config *i = atlas->config;
13306 while (i->next) i = i->next;
13311 font = (
struct nk_font*)
13312 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font));
13314 nk_zero(font,
sizeof(*font));
13315 if (!font)
return 0;
13316 font->config = cfg;
13319 if (!atlas->fonts) {
13320 atlas->fonts = font;
13323 struct nk_font *i = atlas->fonts;
13324 while (i->next) i = i->next;
13328 cfg->font = &font->info;
13331 struct nk_font *f = 0;
13332 struct nk_font_config *c = 0;
13333 NK_ASSERT(atlas->font_num);
13336 cfg->font = &f->info;
13344 if (!config->ttf_data_owned_by_atlas) {
13345 cfg->ttf_blob = atlas->permanent.alloc(atlas->permanent.userdata,0, cfg->ttf_size);
13346 NK_ASSERT(cfg->ttf_blob);
13347 if (!cfg->ttf_blob) {
13351 NK_MEMCPY(cfg->ttf_blob, config->ttf_blob, cfg->ttf_size);
13352 cfg->ttf_data_owned_by_atlas = 1;
13358nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory,
13359 nk_size size,
float height,
const struct nk_font_config *config)
13361 struct nk_font_config cfg;
13366 NK_ASSERT(atlas->temporary.alloc);
13367 NK_ASSERT(atlas->temporary.free);
13368 NK_ASSERT(atlas->permanent.alloc);
13369 NK_ASSERT(atlas->permanent.free);
13370 if (!atlas || !atlas->temporary.alloc || !atlas->temporary.free || !memory || !size ||
13371 !atlas->permanent.alloc || !atlas->permanent.free)
13374 cfg = (config) ? *config: nk_font_config(height);
13375 cfg.ttf_blob = memory;
13376 cfg.ttf_size = size;
13378 cfg.ttf_data_owned_by_atlas = 0;
13379 return nk_font_atlas_add(atlas, &cfg);
13381#ifdef NK_INCLUDE_STANDARD_IO
13383nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
13384 float height,
const struct nk_font_config *config)
13388 struct nk_font_config cfg;
13391 NK_ASSERT(atlas->temporary.alloc);
13392 NK_ASSERT(atlas->temporary.free);
13393 NK_ASSERT(atlas->permanent.alloc);
13394 NK_ASSERT(atlas->permanent.free);
13396 if (!atlas || !file_path)
return 0;
13397 memory = nk_file_load(file_path, &size, &atlas->permanent);
13398 if (!memory)
return 0;
13400 cfg = (config) ? *config: nk_font_config(height);
13401 cfg.ttf_blob = memory;
13402 cfg.ttf_size = size;
13404 cfg.ttf_data_owned_by_atlas = 1;
13405 return nk_font_atlas_add(atlas, &cfg);
13409nk_font_atlas_add_compressed(
struct nk_font_atlas *atlas,
13410 void *compressed_data,
nk_size compressed_size,
float height,
13411 const struct nk_font_config *config)
13413 unsigned int decompressed_size;
13414 void *decompressed_data;
13415 struct nk_font_config cfg;
13418 NK_ASSERT(atlas->temporary.alloc);
13419 NK_ASSERT(atlas->temporary.free);
13420 NK_ASSERT(atlas->permanent.alloc);
13421 NK_ASSERT(atlas->permanent.free);
13423 NK_ASSERT(compressed_data);
13424 NK_ASSERT(compressed_size);
13425 if (!atlas || !compressed_data || !atlas->temporary.alloc || !atlas->temporary.free ||
13426 !atlas->permanent.alloc || !atlas->permanent.free)
13429 decompressed_size = nk_decompress_length((
unsigned char*)compressed_data);
13430 decompressed_data = atlas->permanent.alloc(atlas->permanent.userdata,0,decompressed_size);
13431 NK_ASSERT(decompressed_data);
13432 if (!decompressed_data)
return 0;
13433 nk_decompress((
unsigned char*)decompressed_data, (
unsigned char*)compressed_data,
13434 (
unsigned int)compressed_size);
13436 cfg = (config) ? *config: nk_font_config(height);
13437 cfg.ttf_blob = decompressed_data;
13438 cfg.ttf_size = decompressed_size;
13440 cfg.ttf_data_owned_by_atlas = 1;
13441 return nk_font_atlas_add(atlas, &cfg);
13444nk_font_atlas_add_compressed_base85(
struct nk_font_atlas *atlas,
13445 const char *data_base85,
float height,
const struct nk_font_config *config)
13447 int compressed_size;
13448 void *compressed_data;
13449 struct nk_font *font;
13452 NK_ASSERT(atlas->temporary.alloc);
13453 NK_ASSERT(atlas->temporary.free);
13454 NK_ASSERT(atlas->permanent.alloc);
13455 NK_ASSERT(atlas->permanent.free);
13457 NK_ASSERT(data_base85);
13458 if (!atlas || !data_base85 || !atlas->temporary.alloc || !atlas->temporary.free ||
13459 !atlas->permanent.alloc || !atlas->permanent.free)
13462 compressed_size = (((int)
nk_strlen(data_base85) + 4) / 5) * 4;
13463 compressed_data = atlas->temporary.alloc(atlas->temporary.userdata,0, (
nk_size)compressed_size);
13464 NK_ASSERT(compressed_data);
13465 if (!compressed_data)
return 0;
13466 nk_decode_85((
unsigned char*)compressed_data, (
const unsigned char*)data_base85);
13467 font = nk_font_atlas_add_compressed(atlas, compressed_data,
13468 (
nk_size)compressed_size, height, config);
13469 atlas->temporary.free(atlas->temporary.userdata, compressed_data);
13473#ifdef NK_INCLUDE_DEFAULT_FONT
13475nk_font_atlas_add_default(
struct nk_font_atlas *atlas,
13476 float pixel_height,
const struct nk_font_config *config)
13479 NK_ASSERT(atlas->temporary.alloc);
13480 NK_ASSERT(atlas->temporary.free);
13481 NK_ASSERT(atlas->permanent.alloc);
13482 NK_ASSERT(atlas->permanent.free);
13483 return nk_font_atlas_add_compressed_base85(atlas,
13484 nk_proggy_clean_ttf_compressed_data_base85, pixel_height, config);
13488nk_font_atlas_bake(
struct nk_font_atlas *atlas,
int *width,
int *height,
13489 enum nk_font_atlas_format fmt)
13494 struct nk_font *font_iter;
13495 struct nk_font_baker *baker;
13498 NK_ASSERT(atlas->temporary.alloc);
13499 NK_ASSERT(atlas->temporary.free);
13500 NK_ASSERT(atlas->permanent.alloc);
13501 NK_ASSERT(atlas->permanent.free);
13505 if (!atlas || !width || !height ||
13506 !atlas->temporary.alloc || !atlas->temporary.free ||
13507 !atlas->permanent.alloc || !atlas->permanent.free)
13510#ifdef NK_INCLUDE_DEFAULT_FONT
13512 if (!atlas->font_num)
13513 atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
13515 NK_ASSERT(atlas->font_num);
13516 if (!atlas->font_num)
return 0;
13519 nk_font_baker_memory(&tmp_size, &atlas->glyph_count, atlas->config, atlas->font_num);
13520 tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
13522 if (!tmp)
goto failed;
13525 baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
13526 atlas->glyphs = (
struct nk_font_glyph*)atlas->permanent.alloc(
13527 atlas->permanent.userdata,0,
sizeof(
struct nk_font_glyph)*(
nk_size)atlas->glyph_count);
13528 NK_ASSERT(atlas->glyphs);
13529 if (!atlas->glyphs)
13533 atlas->custom.w = (NK_CURSOR_DATA_W*2)+1;
13534 atlas->custom.h = NK_CURSOR_DATA_H + 1;
13535 if (!nk_font_bake_pack(baker, &img_size, width, height, &atlas->custom,
13536 atlas->config, atlas->font_num, &atlas->temporary))
13540 atlas->pixel = atlas->temporary.alloc(atlas->temporary.userdata,0, img_size);
13541 NK_ASSERT(atlas->pixel);
13546 nk_font_bake(baker, atlas->pixel, *width, *height,
13547 atlas->glyphs, atlas->glyph_count, atlas->config, atlas->font_num);
13548 nk_font_bake_custom_data(atlas->pixel, *width, *height, atlas->custom,
13549 nk_custom_cursor_data, NK_CURSOR_DATA_W, NK_CURSOR_DATA_H,
'.',
'X');
13551 if (fmt == NK_FONT_ATLAS_RGBA32) {
13553 void *img_rgba = atlas->temporary.alloc(atlas->temporary.userdata,0,
13554 (
nk_size)(*width * *height * 4));
13555 NK_ASSERT(img_rgba);
13556 if (!img_rgba)
goto failed;
13557 nk_font_bake_convert(img_rgba, *width, *height, atlas->pixel);
13558 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
13559 atlas->pixel = img_rgba;
13561 atlas->tex_width = *width;
13562 atlas->tex_height = *height;
13565 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
13566 struct nk_font *font = font_iter;
13567 struct nk_font_config *config = font->config;
13568 nk_font_init(font, config->size, config->fallback_glyph, atlas->glyphs,
13575 {{ 0, 3}, {12,19}, { 0, 0}},
13576 {{13, 0}, { 7,16}, { 4, 8}},
13577 {{31, 0}, {23,23}, {11,11}},
13578 {{21, 0}, { 9, 23}, { 5,11}},
13579 {{55,18}, {23, 9}, {11, 5}},
13580 {{73, 0}, {17,17}, { 9, 9}},
13581 {{55, 0}, {17,17}, { 9, 9}}
13584 struct nk_cursor *cursor = &atlas->cursors[i];
13585 cursor->
img.
w = (
unsigned short)*width;
13586 cursor->
img.
h = (
unsigned short)*height;
13587 cursor->
img.
region[0] = (
unsigned short)(atlas->custom.x + nk_cursor_data[i][0].x);
13588 cursor->
img.
region[1] = (
unsigned short)(atlas->custom.y + nk_cursor_data[i][0].y);
13589 cursor->
img.
region[2] = (
unsigned short)nk_cursor_data[i][1].x;
13590 cursor->
img.
region[3] = (
unsigned short)nk_cursor_data[i][1].y;
13591 cursor->size = nk_cursor_data[i][1];
13592 cursor->
offset = nk_cursor_data[i][2];
13595 atlas->temporary.free(atlas->temporary.userdata, tmp);
13596 return atlas->pixel;
13600 if (tmp) atlas->temporary.free(atlas->temporary.userdata, tmp);
13601 if (atlas->glyphs) {
13602 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
13605 if (atlas->pixel) {
13606 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
13612nk_font_atlas_end(
struct nk_font_atlas *atlas,
nk_handle texture,
13616 struct nk_font *font_iter;
13620 null->texture = texture;
13621 null->uv =
nk_vec2(0.5f,0.5f);
13624 null->texture = texture;
13625 null->uv.x = (atlas->custom.x + 0.5f)/(
float)atlas->tex_width;
13626 null->uv.y = (atlas->custom.y + 0.5f)/(
float)atlas->tex_height;
13628 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
13629 font_iter->texture = texture;
13630#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
13631 font_iter->handle.texture = texture;
13635 atlas->cursors[i].img.handle = texture;
13637 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
13639 atlas->tex_width = 0;
13640 atlas->tex_height = 0;
13641 atlas->custom.x = 0;
13642 atlas->custom.y = 0;
13643 atlas->custom.w = 0;
13644 atlas->custom.h = 0;
13647nk_font_atlas_cleanup(
struct nk_font_atlas *atlas)
13650 NK_ASSERT(atlas->temporary.alloc);
13651 NK_ASSERT(atlas->temporary.free);
13652 NK_ASSERT(atlas->permanent.alloc);
13653 NK_ASSERT(atlas->permanent.free);
13654 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
13655 if (atlas->config) {
13656 struct nk_font_config *iter;
13657 for (iter = atlas->config; iter; iter = iter->next) {
13658 struct nk_font_config *i;
13659 for (i = iter->n; i != iter; i = i->n) {
13660 atlas->permanent.free(atlas->permanent.userdata, i->ttf_blob);
13663 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
13664 iter->ttf_blob = 0;
13669nk_font_atlas_clear(
struct nk_font_atlas *atlas)
13672 NK_ASSERT(atlas->temporary.alloc);
13673 NK_ASSERT(atlas->temporary.free);
13674 NK_ASSERT(atlas->permanent.alloc);
13675 NK_ASSERT(atlas->permanent.free);
13676 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
13678 if (atlas->config) {
13679 struct nk_font_config *iter, *next;
13680 for (iter = atlas->config; iter; iter = next) {
13681 struct nk_font_config *i, *n;
13682 for (i = iter->n; i != iter; i = n) {
13685 atlas->permanent.free(atlas->permanent.userdata, i->ttf_blob);
13686 atlas->permanent.free(atlas->permanent.userdata, i);
13690 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
13691 atlas->permanent.free(atlas->permanent.userdata, iter);
13695 if (atlas->fonts) {
13696 struct nk_font *iter, *next;
13697 for (iter = atlas->fonts; iter; iter = next) {
13699 atlas->permanent.free(atlas->permanent.userdata, iter);
13704 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
13771#ifdef NK_KEYSTATE_BASED_INPUT
13975#define NK_COLOR_MAP(NK_COLOR)\
13976 NK_COLOR(NK_COLOR_TEXT, 175,175,175,255) \
13977 NK_COLOR(NK_COLOR_WINDOW, 45, 45, 45, 255) \
13978 NK_COLOR(NK_COLOR_HEADER, 40, 40, 40, 255) \
13979 NK_COLOR(NK_COLOR_BORDER, 65, 65, 65, 255) \
13980 NK_COLOR(NK_COLOR_BUTTON, 50, 50, 50, 255) \
13981 NK_COLOR(NK_COLOR_BUTTON_HOVER, 40, 40, 40, 255) \
13982 NK_COLOR(NK_COLOR_BUTTON_ACTIVE, 35, 35, 35, 255) \
13983 NK_COLOR(NK_COLOR_TOGGLE, 100,100,100,255) \
13984 NK_COLOR(NK_COLOR_TOGGLE_HOVER, 120,120,120,255) \
13985 NK_COLOR(NK_COLOR_TOGGLE_CURSOR, 45, 45, 45, 255) \
13986 NK_COLOR(NK_COLOR_SELECT, 45, 45, 45, 255) \
13987 NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \
13988 NK_COLOR(NK_COLOR_SLIDER, 38, 38, 38, 255) \
13989 NK_COLOR(NK_COLOR_SLIDER_CURSOR, 100,100,100,255) \
13990 NK_COLOR(NK_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \
13991 NK_COLOR(NK_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \
13992 NK_COLOR(NK_COLOR_PROPERTY, 38, 38, 38, 255) \
13993 NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \
13994 NK_COLOR(NK_COLOR_EDIT_CURSOR, 175,175,175,255) \
13995 NK_COLOR(NK_COLOR_COMBO, 45, 45, 45, 255) \
13996 NK_COLOR(NK_COLOR_CHART, 120,120,120,255) \
13997 NK_COLOR(NK_COLOR_CHART_COLOR, 45, 45, 45, 255) \
13998 NK_COLOR(NK_COLOR_CHART_COLOR_HIGHLIGHT, 255, 0, 0, 255) \
13999 NK_COLOR(NK_COLOR_SCROLLBAR, 40, 40, 40, 255) \
14000 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \
14001 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_HOVER, 120,120,120,255) \
14002 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_ACTIVE, 150,150,150,255) \
14003 NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255)
14007#define NK_COLOR(a,b,c,d,e) {b,c,d,e},
14008 NK_COLOR_MAP(NK_COLOR)
14012#define NK_COLOR(a,b,c,d,e) #a,
14013 NK_COLOR_MAP(NK_COLOR)
14020 return nk_color_names[c];
14027 i.data.image = img;
14035 i.data.color = col;
14043 i.data.color =
nk_rgba(0,0,0,0);
14066 style = &ctx->
style;
14067 table = (!table) ? nk_default_color_style: table;
14070 text = &style->
text;
14075 button = &style->
button;
14155 toggle = &style->
option;
14197 slider = &style->
slider;
14308 edit = &style->
edit;
14346 property->padding =
nk_vec2(4,4);
14347 property->border = 1;
14348 property->rounding = 10;
14349 property->draw_begin = 0;
14350 property->draw_end = 0;
14397 chart = &style->
chart;
14408 combo = &style->
combo;
14597 style = &ctx->
style;
14606 struct nk_config_stack_user_font *font_stack;
14607 struct nk_config_stack_user_font_element *element;
14610 if (!ctx)
return 0;
14613 NK_ASSERT(font_stack->head < (
int)
NK_LEN(font_stack->elements));
14614 if (font_stack->head >= (
int)
NK_LEN(font_stack->elements))
14617 element = &font_stack->elements[font_stack->head++];
14626 struct nk_config_stack_user_font *font_stack;
14627 struct nk_config_stack_user_font_element *element;
14630 if (!ctx)
return 0;
14633 NK_ASSERT(font_stack->head > 0);
14634 if (font_stack->head < 1)
14637 element = &font_stack->elements[--font_stack->head];
14638 *element->address = element->old_value;
14641#define NK_STYLE_PUSH_IMPLEMENATION(prefix, type, stack) \
14642nk_style_push_##type(struct nk_context *ctx, prefix##_##type *address, prefix##_##type value)\
14644 struct nk_config_stack_##type * type_stack;\
14645 struct nk_config_stack_##type##_element *element;\
14647 if (!ctx) return 0;\
14648 type_stack = &ctx->stacks.stack;\
14649 NK_ASSERT(type_stack->head < (int)NK_LEN(type_stack->elements));\
14650 if (type_stack->head >= (int)NK_LEN(type_stack->elements))\
14652 element = &type_stack->elements[type_stack->head++];\
14653 element->address = address;\
14654 element->old_value = *address;\
14658#define NK_STYLE_POP_IMPLEMENATION(type, stack) \
14659nk_style_pop_##type(struct nk_context *ctx)\
14661 struct nk_config_stack_##type *type_stack;\
14662 struct nk_config_stack_##type##_element *element;\
14664 if (!ctx) return 0;\
14665 type_stack = &ctx->stacks.stack;\
14666 NK_ASSERT(type_stack->head > 0);\
14667 if (type_stack->head < 1)\
14669 element = &type_stack->elements[--type_stack->head];\
14670 *element->address = element->old_value;\
14673NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk, style_item, style_items)
14674NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,
float, floats)
14675NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk, vec2, vectors)
14676NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,flags, flags)
14677NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk,color, colors)
14679NK_API int NK_STYLE_POP_IMPLEMENATION(style_item, style_items)
14680NK_API int NK_STYLE_POP_IMPLEMENATION(
float,floats)
14681NK_API int NK_STYLE_POP_IMPLEMENATION(vec2, vectors)
14682NK_API int NK_STYLE_POP_IMPLEMENATION(flags,flags)
14683NK_API int NK_STYLE_POP_IMPLEMENATION(color,colors)
14690 if (!ctx)
return 0;
14691 style = &ctx->
style;
14715 style = &ctx->
style;
14725 style = &ctx->
style;
14748#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
14749 nk_draw_list_init(&ctx->draw_list);
14752#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
14757 alloc.userdata.ptr = 0;
14758 alloc.alloc = nk_malloc;
14759 alloc.free = nk_mfree;
14768 if (!memory)
return 0;
14769 nk_setup(ctx, font);
14780 if (!cmds || !pool)
return 0;
14782 nk_setup(ctx, font);
14790 nk_pool_init(&ctx->
pool,
alloc, NK_POOL_DEFAULT_CAPACITY);
14800 if (!
alloc)
return 0;
14801 nk_setup(ctx, font);
14803 nk_pool_init(&ctx->
pool,
alloc, NK_POOL_DEFAULT_CAPACITY);
14807#ifdef NK_INCLUDE_COMMAND_USERDATA
14812 ctx->userdata = handle;
14824 nk_pool_free(&ctx->
pool);
14863 iter->
seq == ctx->
seq) {
14880 nk_free_window(ctx, iter->
popup.
win);
14887 if (it->
seq != ctx->
seq) {
14888 nk_remove_table(iter, it);
14890 nk_free_table(ctx, it);
14898 nk_remove_window(ctx, iter);
14899 nk_free_window(ctx, iter);
14901 }
else iter = iter->
next;
14910 if (!ctx || !buffer)
return;
14914 buffer->
clip = nk_null_rect;
14921 nk_start_buffer(ctx, &win->
buffer);
14929 if (!ctx || !win)
return;
14945 if (!ctx || !win)
return;
14956 if (!ctx || !buffer)
return;
14968 if (!ctx || !win)
return;
14969 nk_finish_buffer(ctx, &win->
buffer);
14975 parent_last->
next = buf->
end;
14991 nk_start_buffer(ctx, &ctx->
overlay);
14995 mouse_bounds.w = cursor->size.x;
14996 mouse_bounds.h = cursor->size.y;
14999 nk_finish_buffer(ctx, &ctx->
overlay);
15045 if (!ctx)
return 0;
15046 if (!ctx->
count)
return 0;
15057 if (!iter)
return 0;
15067 if (!ctx || !cmd || !ctx->
count)
return 0;
15085 unsigned int capacity)
15087 nk_zero(pool,
sizeof(*pool));
15088 pool->
alloc = *alloc;
15094nk_pool_free(
struct nk_pool *pool)
15108 nk_zero(pool,
sizeof(*pool));
15117nk_pool_alloc(
struct nk_pool *pool)
15123 NK_ASSERT(pool->
pages);
15124 if (!pool->
pages)
return 0;
15131 page->next = pool->
pages;
15132 pool->
pages = page;
15147nk_create_page_element(
struct nk_context *ctx)
15156 elem = nk_pool_alloc(&ctx->
pool);
15158 if (!elem)
return 0;
15165 if (!elem)
return 0;
15173nk_link_page_element_into_freelist(
struct nk_context *ctx,
15189 nk_link_page_element_into_freelist(ctx, elem);
15193 {
void *elem_end = (
void*)(elem + 1);
15195 if (elem_end == buffer_end)
15197 else nk_link_page_element_into_freelist(ctx, elem);}
15212 elem = nk_create_page_element(ctx);
15213 if (!elem)
return 0;
15222 nk_free_page_element(ctx, pe);
15260 if (!win || !ctx)
return 0;
15262 struct nk_table *tbl = nk_create_table(ctx);
15264 if (!tbl)
return 0;
15265 nk_push_table(win, tbl);
15277 unsigned int i = 0;
15279 for (i = 0; i <
size; ++i) {
15280 if (iter->
keys[i] == name) {
15282 return &iter->
values[i];
15302 elem = nk_create_page_element(ctx);
15303 if (!elem)
return 0;
15312 nk_free_page_element(ctx, pe);
15315nk_panel_has_header(
nk_flags flags,
const char *title)
15362 case NK_PANEL_MENU:
return style->window.menu_border_color;
15385 struct nk_vec2 scrollbar_size;
15386 struct nk_vec2 panel_padding;
15399 style = &ctx->
style;
15400 font = style->
font;
15405#ifdef NK_INCLUDE_COMMAND_USERDATA
15410 panel_padding = nk_panel_get_padding(style, panel_type);
15414 int left_mouse_down;
15415 int left_mouse_clicked;
15416 int left_mouse_click_in_cursor;
15423 if (nk_panel_has_header(win->
flags, title)) {
15426 }
else header.h = panel_padding.y;
15433 if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
15443 layout->
type = panel_type;
15446 layout->
bounds.
x += panel_padding.x;
15447 layout->
bounds.
w -= 2*panel_padding.x;
15449 layout->
border = nk_panel_get_border(style, win->
flags, panel_type);
15451 }
else layout->
border = 0;
15466 layout->
bounds.
w -= scrollbar_size.x;
15467 if (!nk_panel_is_nonblock(panel_type)) {
15475 if (nk_panel_has_header(win->
flags, title))
15490 layout->
bounds.
y += header.h;
15491 layout->
bounds.
h -= header.h;
15492 layout->
at_y += header.h;
15495 if (ctx->
active == win) {
15509 text.background =
nk_rgba(0,0,0,0);
15512 text.background = background->
data.
color;
15520 button.w = button.h;
15531 if (nk_do_button_symbol(&ws, &win->
buffer, button,
15544 button.x = (header.w + header.x) - button.w;
15551 button.x = header.x;
15564 struct nk_rect label = {0,0,0,0};
15573 label.
w =
NK_CLAMP(0, label.
w, header.x + header.w - label.
x);
15574 nk_widget_text(out, label,(
const char*)title, text_len, &text,
NK_TEXT_LEFT, font);}
15595 layout->
clip = clip;}
15607 struct nk_vec2 scrollbar_size;
15608 struct nk_vec2 panel_padding;
15617 layout = window->
layout;
15618 style = &ctx->
style;
15621 if (!nk_panel_is_sub(layout->
type))
15626 panel_padding = nk_panel_get_padding(style, layout->
type);
15640 empty_space.x = window->
bounds.
x;
15641 empty_space.y = layout->
bounds.
y;
15642 empty_space.h = panel_padding.y;
15643 empty_space.w = window->
bounds.
w;
15647 empty_space.x = window->
bounds.
x;
15648 empty_space.y = layout->
bounds.
y;
15649 empty_space.w = panel_padding.x + layout->
border;
15650 empty_space.h = layout->
bounds.
h;
15655 empty_space.y = layout->
bounds.
y;
15656 empty_space.w = panel_padding.x + layout->
border;
15657 empty_space.h = layout->
bounds.
h;
15659 empty_space.w += scrollbar_size.x;
15664 empty_space.x = window->
bounds.
x;
15666 empty_space.w = window->
bounds.
w;
15678 int scroll_has_scrolling;
15679 float scroll_target;
15680 float scroll_offset;
15685 if (nk_panel_is_sub(layout->
type))
15688 struct nk_window *root_window = window;
15690 while (root_panel->
parent)
15691 root_panel = root_panel->
parent;
15692 while (root_window->
parent)
15693 root_window = root_window->
parent;
15696 scroll_has_scrolling = 0;
15704 root_panel = window->
layout;
15705 while (root_panel->
parent) {
15707 root_panel = root_panel->
parent;
15710 scroll_has_scrolling =
nk_true;
15713 }
else if (!nk_panel_is_sub(layout->
type)) {
15719 }
else scroll_has_scrolling =
nk_false;
15724 scroll.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
15726 scroll.w = scrollbar_size.x;
15729 scroll_offset = (float)*layout->
offset_y;
15730 scroll_step = scroll.h * 0.10f;
15731 scroll_inc = scroll.h * 0.01f;
15732 scroll_target = (
float)(int)(layout->
at_y - scroll.y);
15733 scroll_offset = nk_do_scrollbarv(&state, out, scroll, scroll_has_scrolling,
15734 scroll_offset, scroll_target, scroll_step, scroll_inc,
15737 if (in && scroll_has_scrolling)
15746 scroll.h = scrollbar_size.y;
15748 scroll_offset = (float)*layout->
offset_x;
15749 scroll_target = (
float)(int)(layout->
max_x - scroll.x);
15750 scroll_step = layout->
max_x * 0.05f;
15751 scroll_inc = layout->
max_x * 0.005f;
15752 scroll_offset = nk_do_scrollbarh(&state, out, scroll, scroll_has_scrolling,
15753 scroll_offset, scroll_target, scroll_step, scroll_inc,
15764 if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
15772 struct nk_color border_color = nk_panel_get_border_color(style, layout->
type);
15779 b.
h = padding_y - window->
bounds.
y;
15788 scaler.
w = scrollbar_size.x;
15789 scaler.h = scrollbar_size.y;
15792 scaler.x = layout->
bounds.
x - panel_padding.x * 0.5f;
15793 else scaler.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
15795 scaler.x -= scaler.w;
15804 scaler.y + scaler.h, scaler.x + scaler.w,
15805 scaler.y + scaler.h, item->
data.
color);
15808 scaler.y + scaler.h, scaler.x, scaler.y + scaler.h, item->
data.
color);
15819 if (left_mouse_down && left_mouse_click_in_scaler) {
15822 delta_x = -delta_x;
15826 if (window->
bounds.
w + delta_x >= window_size.
x) {
15827 if ((delta_x < 0) || (delta_x > 0 && in->
mouse.
pos.
x >= scaler.x)) {
15847 if (!nk_panel_is_sub(layout->
type)) {
15850 nk_command_buffer_reset(&window->
buffer);
15852 else nk_finish(ctx, window);
15874 nk_zero(&window->
edit,
sizeof(window->
edit));
15906 elem = nk_create_page_element(ctx);
15907 if (!elem)
return 0;
15917 nk_free_window(ctx, win->
popup.
win);
15926 nk_remove_table(win, it);
15927 nk_free_table(ctx, it);
15936 nk_free_page_element(ctx, pe);}
15944 NK_ASSERT(iter != iter->
next);
15945 if (iter->
name == hash) {
15956 enum nk_window_insert_location loc)
15961 if (!win || !ctx)
return;
15965 NK_ASSERT(iter != iter->
next);
15966 NK_ASSERT(iter != win);
15967 if (iter == win)
return;
15979 if (loc == NK_INSERT_BACK) {
16002 if (win == ctx->
begin || win == ctx->
end) {
16003 if (win == ctx->
begin) {
16008 if (win == ctx->
end) {
16048 NK_ASSERT(!ctx->
current &&
"if this triggers you missed a `nk_end` call");
16049 if (!ctx || ctx->
current || !title || !name)
16053 style = &ctx->
style;
16056 win = nk_find_window(ctx, name_hash, name);
16060 win = (
struct nk_window*)nk_create_window(ctx);
16062 if (!win)
return 0;
16065 nk_insert_window(ctx, win, NK_INSERT_FRONT);
16066 else nk_insert_window(ctx, win, NK_INSERT_BACK);
16071 win->
name = name_hash;
16091 NK_ASSERT(win->
seq != ctx->
seq);
16102 }
else nk_start(ctx, win);
16107 int inpanel, ishovered;
16124 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
16138 if (iter && inpanel && (win != ctx->
end)) {
16145 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
16163 nk_remove_window(ctx, iter);
16164 nk_insert_window(ctx, iter, NK_INSERT_BACK);
16167 if (!iter && ctx->
end != win) {
16171 nk_remove_window(ctx, win);
16172 nk_insert_window(ctx, win, NK_INSERT_BACK);
16193 NK_ASSERT(ctx->
current &&
"if this triggers you forgot to call `nk_begin`");
16235 if (!ctx || !ctx->
current)
return 0;
16243 if (!ctx || !ctx->
current)
return 0;
16288 if (!ctx || !ctx->
current)
return 0;
16296 if (!ctx || !ctx->
current)
return 0;
16319 if (!ctx || !ctx->
current)
return 0;
16327 if (!ctx || !ctx->
current)
return 0;
16337 if (!ctx)
return 0;
16364 return any_hovered || any_active;
16373 if (!ctx)
return 0;
16377 win = nk_find_window(ctx, title_hash,
name);
16378 if (!win)
return 0;
16388 if (!ctx)
return 1;
16392 win = nk_find_window(ctx, title_hash,
name);
16393 if (!win)
return 1;
16403 if (!ctx)
return 1;
16407 win = nk_find_window(ctx, title_hash,
name);
16408 if (!win)
return 1;
16418 if (!ctx)
return 0;
16422 win = nk_find_window(ctx, title_hash,
name);
16423 if (!win)
return 0;
16424 return win == ctx->
active;
16433 return nk_find_window(ctx, title_hash,
name);
16443 NK_ASSERT(ctx->
current != win &&
"You cannot close a currently active window");
16444 if (ctx->
current == win)
return;
16457 NK_ASSERT(ctx->
current != win &&
"You cannot update a currently in procecss window");
16502 win = nk_find_window(ctx, title_hash,
name);
16513 if (!ctx || !cond)
return;
16527 win = nk_find_window(ctx, title_hash,
name);
16538 if (!ctx || !cond)
return;
16553 win = nk_find_window(ctx, title_hash,
name);
16554 if (win && ctx->
end != win) {
16555 nk_remove_window(ctx, win);
16556 nk_insert_window(ctx, win, NK_INSERT_BACK);
16596 popup = (
struct nk_window*)nk_create_window(ctx);
16597 popup->parent = win;
16619 popup->parent = win;
16620 popup->bounds = rect;
16629 nk_start_popup(ctx, win);
16659 nk_free_panel(ctx, popup->
layout);
16688 popup = (
struct nk_window*)nk_create_window(ctx);
16689 popup->parent = win;
16695 int pressed, in_body, in_header;
16696#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
16703 if (pressed && (!in_body || in_header))
16725 NK_ASSERT(popup->
layout);
16727 nk_start_popup(ctx, win);
16732 nk_panel_begin(ctx, 0, panel_type);
16752 if (!ctx || !ctx->
current)
return;
16755 NK_ASSERT(
popup->parent);
16772 if (!
popup->parent)
return;
16773 win =
popup->parent;
16787 nk_finish_popup(ctx, win);
16804 *offset_x =
popup->scrollbar.x;
16806 *offset_y =
popup->scrollbar.y;
16820 popup->scrollbar.x = offset_x;
16821 popup->scrollbar.y = offset_y;
16833 struct nk_rect trigger_bounds)
16840 int is_clicked = 0;
16863 if ((!is_open && !is_clicked))
16908 style = &ctx->
style;
16927 const char *text,
int len,
nk_flags align)
16943 style = &ctx->
style;
16957 const char *label,
nk_flags align)
16963 const char *text,
int len,
nk_flags align)
16979 style = &ctx->
style;
17013 if (!ctx || !ctx->
current)
return;
17017 NK_ASSERT(popup->
parent);
17025 struct nk_rect body = {0,0,0,0};
17034 if (pressed && in_body)
17122 const char *
id,
int is_clicked,
struct nk_rect header,
struct nk_vec2 size)
17138 body.
y = header.
y + header.
h;
17144 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
17145 (!is_open && !is_active && !is_clicked))
return 0;
17171 if (!state)
return 0;
17176 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
17201 if (!state)
return 0;
17206 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
17226 if (!state)
return 0;
17231 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
17251 if (!state)
return 0;
17257 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
17283 if (!state)
return 0;
17289 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
17309 const char *label,
nk_flags align)
17315 const char *text,
int len,
nk_flags align)
17320 const char *text,
int len,
nk_flags align)
17325 const char *label,
nk_flags align)
17383 float total_space,
int columns)
17385 float panel_padding;
17386 float panel_spacing;
17393 padding = nk_panel_get_padding(style, type);
17396 panel_padding = 2 * padding.x;
17397 panel_spacing = (float)
NK_MAX(columns - 1, 0) * spacing.x;
17398 panel_space = total_space - panel_padding - panel_spacing;
17399 return panel_space;
17403 float height,
int cols)
17420 style = &ctx->
style;
17438 if (height == 0.0f)
17440 else layout->
row.
height = height + item_spacing.y;
17446 background.x = win->
bounds.
x;
17447 background.w = win->
bounds.
w;
17448 background.y = layout->
at_y - 1.0f;
17449 background.h = layout->
row.
height + 1.0f;
17455 float height,
int cols,
int width)
17466 nk_panel_layout(ctx, win, height, cols);
17481 NK_ASSERT(pixel_width);
17498 float row_height,
int cols)
17511 nk_panel_layout(ctx, win, row_height, cols);
17541 float ratio = ratio_or_width;
17542 if ((ratio + layout->
row.
filled) > 1.0f)
return;
17570 float height,
int cols,
const float *ratio)
17585 nk_panel_layout(ctx, win, height, cols);
17590 for (i = 0; i < cols; ++i) {
17591 if (ratio[i] < 0.0f)
17593 else r += ratio[i];
17597 layout->
row.
item_width = (r > 0 && n_undef > 0) ? (r / (
float)n_undef):0;
17621 nk_panel_layout(ctx, win, height, 1);
17701 int variable_count = 0;
17702 int min_variable_count = 0;
17703 float min_fixed_width = 0.0f;
17704 float total_fixed_width = 0.0f;
17705 float max_variable_width = 0.0f;
17719 if (width >= 0.0f) {
17720 total_fixed_width += width;
17721 min_fixed_width += width;
17722 }
else if (width < -1.0f) {
17724 total_fixed_width += width;
17725 max_variable_width =
NK_MAX(max_variable_width, width);
17728 min_variable_count++;
17732 if (variable_count) {
17733 float space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
17735 float var_width = (
NK_MAX(space-min_fixed_width,0.0f)) / (
float)variable_count;
17736 int enough_space = var_width >= max_variable_width;
17738 var_width = (
NK_MAX(space-total_fixed_width,0)) / (
float)min_variable_count;
17741 *width = (*width >= 0.0f)? *width: (*width < -1.0f && !enough_space)? -(*width): var_width;
17747 float height,
int widget_count)
17760 nk_panel_layout(ctx, win, height, widget_count);
17818 ret.x = layout->
clip.
x;
17819 ret.y = layout->
clip.
y;
17820 ret.w = layout->
clip.
w;
17837 ret.x = layout->
at_x;
17838 ret.y = layout->
at_y;
17912 const float row_height = layout->
row.
height - spacing.
y;
17913 nk_panel_layout(ctx, win, row_height, layout->
row.
columns);
17925 float item_offset = 0;
17926 float item_width = 0;
17927 float item_spacing = 0;
17928 float panel_space = 0;
17938 style = &ctx->
style;
17942 padding = nk_panel_get_padding(style, layout->
type);
17943 panel_space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
17946 #define NK_FRAC(x) (x - (int)x)
17952 item_offset = (
float)layout->
row.
index * w;
17953 item_width = w + NK_FRAC(item_offset);
17954 item_spacing = (float)layout->
row.
index * spacing.x;
17960 item_width = w + NK_FRAC(item_offset);
17986 w = (ratio * panel_space);
17987 item_spacing = (float)layout->
row.
index * spacing.x;
17989 item_width = w + NK_FRAC(item_offset);
17999 item_offset = (float)layout->
row.
index * item_width;
18000 item_spacing = (
float)layout->
row.
index * spacing.x;
18006 item_spacing = (float)layout->
row.
index * spacing.x;
18013 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
18014 layout->
max_x = (bounds->
x + bounds->
w);
18023 item_spacing = (float)layout->
row.
index * spacing.x;
18035 item_width = w + NK_FRAC(item_offset);
18036 item_spacing = (float)layout->
row.
index * spacing.x;
18040 default: NK_ASSERT(0);
break;
18044 bounds->
w = item_width;
18047 bounds->
x = layout->
at_x + item_offset + item_spacing + padding.x;
18048 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
18049 layout->
max_x = bounds->
x + bounds->
w;
18068 nk_panel_alloc_row(ctx, win);
18126 struct nk_rect header = {0,0,0,0};
18127 struct nk_rect sym = {0,0,0,0};
18143 style = &ctx->
style;
18152 widget_state =
nk_widget(&header, ctx);
18157 text.background =
nk_rgba(0,0,0,0);
18159 text.background = background->
data.
color;
18190 button, 0, style->
font);
18194 sym.
x = sym.
x + sym.
w + 4 * item_spacing.x;
18201 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
18202 label.x = sym.
x + sym.
w + item_spacing.x;
18204 label.w = header.
w - (sym.
w + item_spacing.y + style->
tab.
indent);
18208 nk_widget_text(out, label, title,
nk_strlen(title), &text,
18223 const char *hash,
int len,
int line)
18235 state = nk_find_value(win, tree_hash);
18237 state = nk_add_value(ctx, win, tree_hash, 0);
18238 *state = initial_state;
18246 return nk_tree_state_base(ctx, type, 0, title, state);
18252 return nk_tree_state_base(ctx, type, &img, title, state);
18276 const char *hash,
int len,
int line)
18278 return nk_tree_base(ctx,
type, 0, title, initial_state, hash, len, line);
18283 const char *hash,
int len,
int seed)
18285 return nk_tree_base(ctx,
type, &img, title, initial_state, hash, len, seed);
18294 struct nk_image *img,
const char *title,
int title_len,
18311 struct nk_rect header = {0,0,0,0};
18312 struct nk_rect sym = {0,0,0,0};
18328 style = &ctx->
style;
18338 widget_state =
nk_widget(&header, ctx);
18343 text.background =
nk_rgba(0,0,0,0);
18345 text.background = background->
data.
color;
18380 text_width += (4 * padding.x);
18382 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
18383 label.x = sym.
x + sym.
w + item_spacing.x;
18385 label.w =
NK_MIN(header.
w - (sym.
w + item_spacing.y + style->
tab.
indent), text_width);
18391 }
else nk_do_selectable(&dummy, &win->
buffer, label, title, title_len,
NK_TEXT_LEFT,
18406 int *selected,
const char *hash,
int len,
int line)
18418 state = nk_find_value(win, tree_hash);
18420 state = nk_add_value(ctx, win, tree_hash, 0);
18421 *state = initial_state;
18422 }
return nk_tree_element_image_push_hashed_base(ctx, type, img, title,
18428 int *selected,
const char *hash,
int len,
int seed)
18430 return nk_tree_element_base(ctx, type, 0, title, initial_state, selected, hash, len, seed);
18435 int *selected,
const char *hash,
int len,
int seed)
18437 return nk_tree_element_base(ctx, type, &img, title, initial_state, selected, hash, len, seed);
18462 nk_panel_alloc_space(&
bounds, ctx);
18472 nk_zero(&panel,
sizeof(panel));
18474 panel.
flags = flags;
18475 panel.scrollbar.x = *x_offset;
18476 panel.scrollbar.y = *y_offset;
18478 panel.layout = (
struct nk_panel*)nk_create_panel(ctx);
18484 panel.layout->
offset_x = x_offset;
18485 panel.layout->
offset_y = y_offset;
18487 win->
layout = panel.layout;
18511 struct nk_vec2 panel_padding;
18530 pan.bounds.x = g->
bounds.
x - panel_padding.x;
18531 pan.bounds.w = g->
bounds.
w + 2 * panel_padding.x;
18534 pan.bounds.x -= g->
border;
18535 pan.bounds.y -= g->
border;
18536 pan.bounds.w += 2*g->
border;
18537 pan.bounds.h += 2*g->
border;
18545 pan.flags = g->
flags;
18546 pan.buffer = win->
buffer;
18552 nk_unify(&clip, &parent->
clip, pan.bounds.
x, pan.bounds.y,
18553 pan.bounds.x + pan.bounds.w, pan.bounds.y + pan.bounds.h + panel_padding.x);
18557 win->
buffer = pan.buffer;
18572 const char *title,
nk_flags flags)
18591 x_offset = nk_find_value(win, id_hash);
18593 x_offset = nk_add_value(ctx, win, id_hash, 0);
18594 y_offset = nk_add_value(ctx, win, id_hash+1, 0);
18596 NK_ASSERT(x_offset);
18597 NK_ASSERT(y_offset);
18598 if (!x_offset || !y_offset)
return 0;
18599 *x_offset = *y_offset = 0;
18600 }
else y_offset = nk_find_value(win, id_hash+1);
18633 x_offset_ptr = nk_find_value(win, id_hash);
18634 if (!x_offset_ptr) {
18635 x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
18636 y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
18638 NK_ASSERT(x_offset_ptr);
18639 NK_ASSERT(y_offset_ptr);
18640 if (!x_offset_ptr || !y_offset_ptr)
return;
18641 *x_offset_ptr = *y_offset_ptr = 0;
18642 }
else y_offset_ptr = nk_find_value(win, id_hash+1);
18644 *x_offset = *x_offset_ptr;
18646 *y_offset = *y_offset_ptr;
18668 x_offset_ptr = nk_find_value(win, id_hash);
18669 if (!x_offset_ptr) {
18670 x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
18671 y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
18673 NK_ASSERT(x_offset_ptr);
18674 NK_ASSERT(y_offset_ptr);
18675 if (!x_offset_ptr || !y_offset_ptr)
return;
18676 *x_offset_ptr = *y_offset_ptr = 0;
18677 }
else y_offset_ptr = nk_find_value(win, id_hash+1);
18678 *x_offset_ptr = x_offset;
18679 *y_offset_ptr = y_offset;
18691 const char *title,
nk_flags flags,
int row_height,
int row_count)
18707 if (!ctx || !view || !title)
return 0;
18710 style = &ctx->
style;
18712 row_height +=
NK_MAX(0, (
int)item_spacing.y);
18717 x_offset = nk_find_value(win, title_hash);
18719 x_offset = nk_add_value(ctx, win, title_hash, 0);
18720 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
18722 NK_ASSERT(x_offset);
18723 NK_ASSERT(y_offset);
18724 if (!x_offset || !y_offset)
return 0;
18725 *x_offset = *y_offset = 0;
18726 }
else y_offset = nk_find_value(win, title_hash+1);
18737 view->
count = (int)
NK_MAX(nk_iceilf((layout->
clip.
h)/(float)row_height),0);
18751 NK_ASSERT(view->
ctx);
18753 if (!view || !view->
ctx)
return;
18779 nk_layout_peek(&bounds, ctx);
18791 nk_layout_peek(&bounds, ctx);
18803 nk_layout_peek(&bounds, ctx);
18815 nk_layout_peek(&bounds, ctx);
18827 nk_layout_peek(&bounds, ctx);
18841 c.
x = (float)((
int)c.
x);
18842 c.
y = (float)((
int)c.
y);
18843 c.
w = (float)((
int)c.
w);
18844 c.
h = (float)((
int)c.
h);
18846 nk_layout_peek(&bounds, ctx);
18847 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
18863 c.
x = (float)((
int)c.
x);
18864 c.
y = (float)((
int)c.
y);
18865 c.
w = (float)((
int)c.
w);
18866 c.
h = (float)((
int)c.
h);
18868 nk_layout_peek(&bounds, ctx);
18869 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
18885 c.
x = (float)((
int)c.
x);
18886 c.
y = (float)((
int)c.
y);
18887 c.
w = (float)((
int)c.
w);
18888 c.
h = (float)((
int)c.
h);
18890 nk_layout_peek(&bounds, ctx);
18891 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
18911 nk_panel_alloc_space(bounds, ctx);
18927 bounds->
x = (float)((
int)bounds->
x);
18928 bounds->
y = (float)((
int)bounds->
y);
18929 bounds->
w = (float)((
int)bounds->
w);
18930 bounds->
h = (float)((
int)bounds->
h);
18932 c.
x = (float)((
int)c.
x);
18933 c.
y = (float)((
int)c.
y);
18934 c.
w = (float)((
int)c.
w);
18935 c.
h = (float)((
int)c.
h);
18937 nk_unify(&v, &c, bounds->
x, bounds->
y, bounds->
x + bounds->
w, bounds->
y + bounds->
h);
18953 struct nk_vec2 panel_padding;
18962 style = &ctx->
style;
18966 panel_padding = nk_panel_get_padding(style, layout->
type);
18968 bounds->
w += panel_padding.x;
18969 bounds->
x -= panel_padding.x;
18970 }
else bounds->
x -= item_padding.
x;
18973 bounds->
w += panel_padding.x;
18974 else bounds->
w += item_padding.
x;
18983 int i, index, rows;
18997 for (i = 0; i < rows; ++i)
18998 nk_panel_alloc_row(ctx, win);
19004 for (i = 0; i < cols; ++i)
19005 nk_panel_alloc_space(&none, ctx);
19019 const char *
string,
int len,
const struct nk_text *t,
19027 if (!o || !t)
return;
19029 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
19030 label.x = 0; label.w = 0;
19031 label.y = b.
y + t->padding.y;
19035 text_width += (2.0f * t->padding.x);
19039 label.x = b.
x + t->padding.x;
19040 label.w =
NK_MAX(0, b.
w - 2 * t->padding.x);
19042 label.w =
NK_MAX(1, 2 * t->padding.x + (
float)text_width);
19043 label.x = (b.
x + t->padding.x + ((b.
w - 2 * t->padding.x) - label.w) / 2);
19044 label.x =
NK_MAX(b.
x + t->padding.x, label.x);
19045 label.w =
NK_MIN(b.
x + b.
w, label.x + label.w);
19046 if (label.w >= label.x) label.w -= label.x;
19048 label.x =
NK_MAX(b.
x + t->padding.x, (b.
x + b.
w) - (2 * t->padding.x + (
float)text_width));
19049 label.w = (float)text_width + 2 * t->padding.x;
19054 label.y = b.
y + b.
h/2.0f - (float)f->
height/2.0f;
19060 nk_draw_text(o, label, (
const char*)
string, len, f, t->background, t->text);
19064 const char *
string,
int len,
const struct nk_text *t,
19077 if (!o || !t)
return;
19080 text.background = t->background;
19081 text.text = t->text;
19083 b.
w =
NK_MAX(b.
w, 2 * t->padding.x);
19084 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
19085 b.
h = b.
h - 2 * t->padding.y;
19087 line.x = b.
x + t->padding.x;
19088 line.y = b.
y + t->padding.y;
19089 line.w = b.
w - 2 * t->padding.x;
19090 line.h = 2 * t->padding.y + f->
height;
19092 fitting = nk_text_clamp(f,
string, len, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
19093 while (done < len) {
19094 if (!fitting || line.y + line.h >= (b.
y + b.
h))
break;
19095 nk_widget_text(o, line, &
string[done], fitting, &text,
NK_TEXT_LEFT, f);
19097 line.y += f->
height + 2 * t->padding.y;
19098 fitting = nk_text_clamp(f, &
string[done], len - done, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
19118 style = &ctx->
style;
19119 nk_panel_alloc_space(&bounds, ctx);
19122 text.padding.
x = item_padding.
x;
19123 text.padding.y = item_padding.
y;
19126 nk_widget_text(&win->
buffer, bounds, str, len, &text, alignment, style->
font);
19145 style = &ctx->
style;
19146 nk_panel_alloc_space(&bounds, ctx);
19149 text.padding.
x = item_padding.
x;
19150 text.padding.y = item_padding.
y;
19153 nk_widget_text_wrap(&win->
buffer, bounds, str, len, &text, style->
font);
19155#ifdef NK_INCLUDE_STANDARD_VARARGS
19158 struct nk_color color,
const char *fmt, ...)
19161 va_start(args, fmt);
19162 nk_labelfv_colored(ctx, flags, color, fmt, args);
19167 const char *fmt, ...)
19170 va_start(args, fmt);
19171 nk_labelfv_colored_wrap(ctx, color, fmt, args);
19178 va_start(args, fmt);
19179 nk_labelfv(ctx, flags, fmt, args);
19183nk_labelf_wrap(
struct nk_context *ctx,
const char *fmt,...)
19186 va_start(args, fmt);
19187 nk_labelfv_wrap(ctx, fmt, args);
19192 struct nk_color color,
const char *fmt, va_list args)
19195 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19201 const char *fmt, va_list args)
19204 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19212 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19217nk_labelfv_wrap(
struct nk_context *ctx,
const char *fmt, va_list args)
19220 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19225nk_value_bool(
struct nk_context *ctx,
const char *prefix,
int value)
19227 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %s", prefix, ((value) ?
"true":
"false"));
19230nk_value_int(
struct nk_context *ctx,
const char *prefix,
int value)
19232 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %d", prefix, value);
19235nk_value_uint(
struct nk_context *ctx,
const char *prefix,
unsigned int value)
19237 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %u", prefix, value);
19240nk_value_float(
struct nk_context *ctx,
const char *prefix,
float value)
19242 double double_value = (double)value;
19243 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %.3f", prefix, double_value);
19248 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%d, %d, %d, %d)", p, c.
r, c.
g, c.
b, c.
a);
19254 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%.2f, %.2f, %.2f, %.2f)",
19255 p, c[0], c[1], c[2], c[3]);
19258nk_value_color_hex(
struct nk_context *ctx,
const char *prefix,
struct nk_color color)
19328 nk_zero(&s,
sizeof(s));
19329 s.handle.ptr = ptr;
19331 s.region[0] = (
unsigned short)r.x;
19332 s.region[1] = (
unsigned short)r.y;
19333 s.region[2] = (
unsigned short)r.w;
19334 s.region[3] = (
unsigned short)r.h;
19341 nk_zero(&s,
sizeof(s));
19344 s.region[0] = (
unsigned short)r.x;
19345 s.region[1] = (
unsigned short)r.y;
19346 s.region[2] = (
unsigned short)r.w;
19347 s.region[3] = (
unsigned short)r.h;
19355 nk_zero(&s,
sizeof(s));
19358 s.region[0] = (
unsigned short)r.x;
19359 s.region[1] = (
unsigned short)r.y;
19360 s.region[2] = (
unsigned short)r.w;
19361 s.region[3] = (
unsigned short)r.h;
19368 nk_zero(&s,
sizeof(s));
19381 nk_zero(&s,
sizeof(s));
19383 s.handle.ptr = ptr;
19395 nk_zero(&s,
sizeof(s));
19408 return !(img->
w == 0 && img->
h == 0);
19465 text.background = background;
19466 text.text = foreground;
19477 nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background);
19495 points[2].
x, points[2].
y, foreground);
19507 nk_widget_state_reset(state);
19516#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
19536 background = &style->
hover;
19538 background = &style->
active;
19539 else background = &style->
normal;
19558 if (!out || !style)
19582 background = nk_draw_button(out, bounds, state, style);
19586 text.background = background->
data.
color;
19595 nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
19612 if (!out || !style || !font || !
string)
19615 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19617 nk_draw_button_text(out, &bounds, &content, *state, style,
string, len, align, font);
19631 background = nk_draw_button(out, bounds, state, style);
19641 nk_draw_symbol(out,
type, *content, bg, sym, 1, font);
19644nk_do_button_symbol(
nk_flags *state,
19657 if (!out || !style || !font || !state)
19660 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19662 nk_draw_button_symbol(out, &bounds, &content, *state, style, symbol, font);
19671 nk_draw_button(out, bounds, state, style);
19675nk_do_button_image(
nk_flags *state,
19686 if (!out || !style || !state)
19689 ret = nk_do_button(state, out, bounds, style, in, b, &content);
19696 nk_draw_button_image(out, &bounds, &content, *state, style, &img);
19712 background = nk_draw_button(out, bounds, state, style);
19714 text.background = background->
data.
color;
19734nk_do_button_text_symbol(
nk_flags *state,
19741 struct nk_rect tri = {0,0,0,0};
19747 if (!out || !style || !font)
19750 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19751 tri.
y = content.
y + (content.
h/2) - font->
height/2;
19754 tri.
x = (content.
x + content.
w) - (2 * style->
padding.
x + tri.
w);
19756 }
else tri.
x = content.
x + 2 * style->
padding.
x;
19760 nk_draw_button_text_symbol(out, &bounds, &content, &tri,
19761 *state, style, str, len, symbol, font);
19769 const char *str,
int len,
const struct nk_user_font *font,
19774 background = nk_draw_button(out, bounds, state, style);
19778 text.background = background->
data.
color;
19791nk_do_button_text_image(
nk_flags *state,
19805 if (!out || !font || !style || !str)
19808 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19810 icon.w = icon.h = bounds.
h - 2 * style->
padding.
y;
19812 icon.x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.w);
19813 icon.x =
NK_MAX(icon.x, 0);
19814 }
else icon.x = bounds.
x + 2 * style->
padding.
x;
19822 nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img);
19836 struct nk_config_stack_button_behavior *button_stack;
19837 struct nk_config_stack_button_behavior_element *element;
19840 if (!ctx)
return 0;
19843 NK_ASSERT(button_stack->head < (
int)
NK_LEN(button_stack->elements));
19844 if (button_stack->head >= (
int)
NK_LEN(button_stack->elements))
19847 element = &button_stack->elements[button_stack->head++];
19856 struct nk_config_stack_button_behavior *button_stack;
19857 struct nk_config_stack_button_behavior_element *element;
19860 if (!ctx)
return 0;
19863 NK_ASSERT(button_stack->head > 0);
19864 if (button_stack->head < 1)
19867 element = &button_stack->elements[--button_stack->head];
19868 *element->address = element->old_value;
19892 if (!state)
return 0;
19902 if (!ctx)
return 0;
19937 if (!state)
return 0;
19969 if (!state)
return 0;
19978 if (!ctx)
return 0;
20002 if (!state)
return 0;
20011 if (!ctx)
return 0;
20017 const char *text,
int len,
nk_flags align)
20036 if (!state)
return 0;
20044 const char* text,
int len,
nk_flags align)
20047 if (!ctx)
return 0;
20051 const char *label,
nk_flags align)
20057 const char *title,
nk_flags align)
20083 if (!state)
return 0;
20091 const char *text,
int len,
nk_flags align)
20096 const char *label,
nk_flags align)
20102 const char *label,
nk_flags text_alignment)
20119 nk_widget_state_reset(state);
20134 const struct nk_rect *cursors,
const char *
string,
int len,
20143 background = &style->
hover;
20147 background = &style->
hover;
20151 background = &style->
normal;
20167 text.padding.x = 0;
20168 text.padding.y = 0;
20170 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
20176 const struct nk_rect *cursors,
const char *
string,
int len,
20185 background = &style->
hover;
20189 background = &style->
hover;
20193 background = &style->
normal;
20209 text.padding.x = 0;
20210 text.padding.y = 0;
20212 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
20217 int *active,
const char *str,
int len,
enum nk_toggle_type type,
20230 if (!out || !style || !font || !active)
20244 select.
h = select.
w;
20245 select.
y = r.
y + r.
h/2.0f - select.
h/2.0f;
20255 label.
x = select.
x + select.
w + style->
spacing;
20256 label.
y = select.
y;
20258 label.
h = select.
w;
20261 was_active = *active;
20262 *active = nk_toggle_behavior(in, bounds, state, *active);
20267 if (type == NK_TOGGLE_CHECK) {
20268 nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
20270 nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
20274 return (was_active != *active);
20299 style = &ctx->
style;
20303 if (!state)
return active;
20306 text, len, NK_TOGGLE_CHECK, &style->
checkbox, in, style->
font);
20311 unsigned int flags,
unsigned int value)
20316 if (!ctx || !text)
return flags;
20317 old_active = (int)((flags & value) & value);
20320 else flags &= ~value;
20330 if (!ctx || !text || !active)
return 0;
20333 return old_val != *active;
20337 unsigned int *flags,
unsigned int value)
20343 if (!ctx || !text || !flags)
return 0;
20345 active = (int)((*flags & value) & value);
20347 if (active) *flags |= value;
20348 else *flags &= ~value;
20358 unsigned int flags,
unsigned int value)
20367 unsigned int *flags,
unsigned int value)
20394 style = &ctx->
style;
20398 if (!state)
return (
int)state;
20401 text, len, NK_TOGGLE_OPTION, &style->
option, in, style->
font);
20411 if (!ctx || !text || !active)
return 0;
20412 old_value = *active;
20414 return old_value != *active;
20438 const struct nk_rect *bounds,
20444 text.padding = style->
padding;
20449 background = &style->
pressed;
20452 background = &style->
hover;
20455 background = &style->
normal;
20473 text.background =
nk_rgba(0,0,0,0);
20476 text.background = background->
data.
color;
20480 else nk_draw_symbol(out, sym, *icon, text.background, text.text, 1, font);
20482 nk_widget_text(out, *bounds,
string, len, &text, align, font);
20486 struct nk_rect bounds,
const char *str,
int len,
nk_flags align,
int *value,
20501 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
20502 old_value = *value;
20512 *value = !(*value);
20516 nk_draw_selectable(out, *state, style, *value, &bounds, 0,0,
NK_SYMBOL_NONE, str, len, align, font);
20518 return old_value != *value;
20522 struct nk_rect bounds,
const char *str,
int len,
nk_flags align,
int *value,
20538 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
20539 old_value = *value;
20547 *value = !(*value);
20550 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
20552 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
20554 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
20563 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, img,
NK_SYMBOL_NONE, str, len, align, font);
20565 return old_value != *value;
20569 struct nk_rect bounds,
const char *str,
int len,
nk_flags align,
int *value,
20585 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
20586 old_value = *value;
20594 *value = !(*value);
20597 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
20599 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
20601 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
20610 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, 0, sym, str, len, align, font);
20612 return old_value != *value;
20636 style = &ctx->
style;
20639 if (!state)
return 0;
20646 const char *str,
int len,
nk_flags align,
int *value)
20665 style = &ctx->
style;
20668 if (!state)
return 0;
20671 str, len, align, value, &img, &style->
selectable, in, style->
font);
20675 const char *str,
int len,
nk_flags align,
int *value)
20694 style = &ctx->
style;
20697 if (!state)
return 0;
20700 str, len, align, value, sym, &style->
selectable, in, style->
font);
20704 const char *title,
nk_flags align,
int *value)
20718 const char *str,
nk_flags align,
int *value)
20727 const char *str,
nk_flags align,
int value)
20732 const char *str,
int len,
nk_flags align,
int value)
20738 const char *title,
int title_len,
nk_flags align,
int value)
20744 const char *title,
nk_flags align,
int value)
20760 struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
20761 float slider_step,
float slider_steps)
20763 int left_mouse_down;
20764 int left_mouse_click_in_cursor;
20767 nk_widget_state_reset(state);
20772 if (left_mouse_down && left_mouse_click_in_cursor) {
20774 const float d = in->
mouse.
pos.
x - (visual_cursor->
x+visual_cursor->
w*0.5f);
20775 const float pxstep = bounds.
w / slider_steps;
20779 if (
NK_ABS(d) >= pxstep) {
20780 const float steps = (float)((
int)(
NK_ABS(d) / pxstep));
20781 slider_value += (d > 0) ? (slider_step*steps) : -(slider_step*steps);
20782 slider_value =
NK_CLAMP(slider_min, slider_value, slider_max);
20783 ratio = (slider_value - slider_min)/slider_step;
20784 logical_cursor->
x = bounds.
x + (logical_cursor->
w * ratio);
20797 return slider_value;
20802 const struct nk_rect *visual_cursor,
float min,
float value,
float max)
20817 background = &style->
active;
20821 background = &style->
hover;
20825 background = &style->
normal;
20831 bar.y = (visual_cursor->
y + visual_cursor->
h/2) - bounds->
h/12;
20833 bar.h = bounds->
h/6;
20836 fill.w = (visual_cursor->
x + (visual_cursor->
w/2.0f)) - bar.x;
20861 float min,
float val,
float max,
float step,
20865 float slider_range;
20868 float slider_value;
20869 float slider_steps;
20870 float cursor_offset;
20872 struct nk_rect visual_cursor;
20873 struct nk_rect logical_cursor;
20877 if (!out || !style)
20892 button.y = bounds.
y;
20893 button.w = bounds.
h;
20894 button.h = bounds.
h;
20897 button.x = bounds.
x;
20903 button.x = (bounds.
x + bounds.
w) - button.w;
20908 bounds.
x = bounds.
x + button.w + style->
spacing.
x;
20909 bounds.
w = bounds.
w - (2*button.w + 2*style->
spacing.
x);
20917 slider_max =
NK_MAX(min, max);
20918 slider_min =
NK_MIN(min, max);
20919 slider_value =
NK_CLAMP(slider_min, val, slider_max);
20920 slider_range = slider_max - slider_min;
20921 slider_steps = slider_range / step;
20922 cursor_offset = (slider_value - slider_min) / step;
20927 logical_cursor.
h = bounds.
h;
20928 logical_cursor.
w = bounds.
w / slider_steps;
20929 logical_cursor.
x = bounds.
x + (logical_cursor.
w * cursor_offset);
20930 logical_cursor.
y = bounds.
y;
20934 visual_cursor.
y = (bounds.
y + bounds.
h*0.5f) - visual_cursor.
h*0.5f;
20935 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
20937 slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
20938 in, bounds, slider_min, slider_max, slider_value, step, slider_steps);
20939 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
20943 nk_draw_slider(out, *state, style, &bounds, &visual_cursor, slider_min, slider_value, slider_max);
20945 return slider_value;
20969 style = &ctx->
style;
20973 if (!state)
return ret;
20976 old_value = *value;
20978 old_value, max_value, value_step, &style->
slider, in, style->
font);
20979 return (old_value > *value || old_value < *value);
20989 float value = (float)val;
20997 float value = (float)*val;
20998 ret =
nk_slider_float(ctx, (
float)min, &value, (
float)max, (
float)step);
21015 int left_mouse_down = 0;
21016 int left_mouse_click_in_cursor = 0;
21018 nk_widget_state_reset(state);
21019 if (!in || !modifiable)
return value;
21026 if (in && left_mouse_down && left_mouse_click_in_cursor) {
21027 if (left_mouse_down && left_mouse_click_in_cursor) {
21028 float ratio =
NK_MAX(0, (
float)(in->
mouse.
pos.
x - cursor.
x)) / (float)cursor.
w;
21054 background = &style->
active;
21057 background = &style->
hover;
21060 background = &style->
normal;
21088 if (!out || !style)
return 0;
21094 prog_scale = (float)value / (
float)max;
21097 prog_value =
NK_MIN(value, max);
21098 prog_value = nk_progress_behavior(state, in, bounds, cursor,max, prog_value, modifiable);
21099 cursor.w = cursor.w * prog_scale;
21103 nk_draw_progress(out, *state, style, &bounds, &cursor, value, max);
21127 style = &ctx->
style;
21130 if (!state)
return 0;
21135 *cur, max, is_modifyable, &style->
progress, in);
21136 return (*cur != old_value);
21155 int has_scrolling,
const struct nk_rect *scroll,
21157 const struct nk_rect *empty1,
float scroll_offset,
21161 int left_mouse_down;
21162 int left_mouse_clicked;
21163 int left_mouse_click_in_cursor;
21164 float scroll_delta;
21166 nk_widget_state_reset(state);
21167 if (!in)
return scroll_offset;
21177 if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
21179 float pixel, delta;
21184 delta = (pixel / scroll->
h) * target;
21185 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
h);
21186 cursor_y = scroll->
y + ((scroll_offset/target) * scroll->
h);
21191 delta = (pixel / scroll->
w) * target;
21192 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
w);
21193 cursor_x = scroll->
x + ((scroll_offset/target) * scroll->
w);
21200 scroll_offset =
NK_MAX(0, scroll_offset - scroll->
h);
21201 else scroll_offset =
NK_MAX(0, scroll_offset - scroll->
w);
21206 scroll_offset =
NK_MIN(scroll_offset + scroll->
h, target - scroll->
h);
21207 else scroll_offset =
NK_MIN(scroll_offset + scroll->
w, target - scroll->
w);
21208 }
else if (has_scrolling) {
21209 if ((scroll_delta < 0 || (scroll_delta > 0))) {
21211 scroll_offset = scroll_offset + scroll_step * (-scroll_delta);
21213 scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
h);
21214 else scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
w);
21220 if (o ==
NK_VERTICAL) scroll_offset = target - scroll->
h;
21227 return scroll_offset;
21232 const struct nk_rect *scroll)
21239 background = &style->
active;
21242 background = &style->
hover;
21245 background = &style->
normal;
21266 float offset,
float target,
float step,
float button_pixel_inc,
21275 float scroll_offset;
21277 float scroll_ratio;
21282 if (!out || !style)
return 0;
21286 if (target <= scroll.
h)
return 0;
21294 button.x = scroll.
x;
21295 button.w = scroll.
w;
21296 button.h = scroll.
w;
21298 scroll_h =
NK_MAX(scroll.
h - 2 * button.h,0);
21299 scroll_step =
NK_MIN(step, button_pixel_inc);
21302 button.y = scroll.
y;
21303 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
21305 offset = offset - scroll_step;
21308 button.y = scroll.
y + scroll.
h - button.h;
21309 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
21311 offset = offset + scroll_step;
21313 scroll.
y = scroll.
y + button.h;
21314 scroll.
h = scroll_h;
21318 scroll_step =
NK_MIN(step, scroll.
h);
21319 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
h);
21320 scroll_ratio = scroll.
h / target;
21321 scroll_off = scroll_offset / target;
21325 cursor.y = scroll.
y + (scroll_off * scroll.
h) + style->
border + style->
padding.
y;
21330 empty_north.x = scroll.
x;
21331 empty_north.y = scroll.
y;
21332 empty_north.w = scroll.
w;
21333 empty_north.h =
NK_MAX(cursor.y - scroll.
y, 0);
21335 empty_south.x = scroll.
x;
21336 empty_south.y = cursor.y + cursor.h;
21337 empty_south.w = scroll.
w;
21338 empty_south.h =
NK_MAX((scroll.
y + scroll.
h) - (cursor.y + cursor.h), 0);
21341 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
21342 &empty_north, &empty_south, scroll_offset, target, scroll_step,
NK_VERTICAL);
21343 scroll_off = scroll_offset / target;
21348 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
21350 return scroll_offset;
21355 float offset,
float target,
float step,
float button_pixel_inc,
21364 float scroll_offset;
21366 float scroll_ratio;
21370 if (!out || !style)
return 0;
21374 scroll.
w =
NK_MAX(scroll.
w, 2 * scroll.
h);
21375 if (target <= scroll.
w)
return 0;
21382 button.y = scroll.
y;
21383 button.w = scroll.
h;
21384 button.h = scroll.
h;
21386 scroll_w = scroll.
w - 2 * button.w;
21387 scroll_step =
NK_MIN(step, button_pixel_inc);
21390 button.x = scroll.
x;
21391 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
21393 offset = offset - scroll_step;
21396 button.x = scroll.
x + scroll.
w - button.w;
21397 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
21399 offset = offset + scroll_step;
21401 scroll.
x = scroll.
x + button.w;
21402 scroll.
w = scroll_w;
21406 scroll_step =
NK_MIN(step, scroll.
w);
21407 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
w);
21408 scroll_ratio = scroll.
w / target;
21409 scroll_off = scroll_offset / target;
21412 cursor.w = (scroll_ratio * scroll.
w) - (2*style->
border + 2*style->
padding.
x);
21413 cursor.x = scroll.
x + (scroll_off * scroll.
w) + style->
border + style->
padding.
x;
21418 empty_west.x = scroll.
x;
21419 empty_west.y = scroll.
y;
21420 empty_west.w = cursor.x - scroll.
x;
21421 empty_west.h = scroll.
h;
21423 empty_east.x = cursor.x + cursor.w;
21424 empty_east.y = scroll.
y;
21425 empty_east.w = (scroll.
x + scroll.
w) - (cursor.x + cursor.w);
21426 empty_east.h = scroll.
h;
21429 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
21430 &empty_west, &empty_east, scroll_offset, target, scroll_step,
NK_HORIZONTAL);
21431 scroll_off = scroll_offset / target;
21432 cursor.x = scroll.
x + (scroll_off * scroll.
w);
21436 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
21438 return scroll_offset;
21450struct nk_text_find {
21453 int first_char, length;
21457struct nk_text_edit_row {
21460 float baseline_y_delta;
21471#define NK_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
21474nk_textedit_get_width(
const struct nk_text_edit *edit,
int line_start,
int char_id,
21483nk_textedit_layout_row(
struct nk_text_edit_row *r,
struct nk_text_edit *edit,
21484 int line_start_id,
float row_height,
const struct nk_user_font *font)
21489 const char *remaining;
21493 const struct nk_vec2 size = nk_text_calculate_text_bounds(font,
21494 text, (
int)(end - text), row_height, &remaining, 0, &glyphs, NK_STOP_ON_NEW_LINE);
21498 r->baseline_y_delta = size.
y;
21501 r->num_chars = glyphs;
21504nk_textedit_locate_coord(
struct nk_text_edit *edit,
float x,
float y,
21507 struct nk_text_edit_row r;
21509 float base_y = 0, prev_x;
21513 r.ymin = r.ymax = 0;
21518 nk_textedit_layout_row(&r, edit, i, row_height, font);
21519 if (r.num_chars <= 0)
21522 if (i==0 && y < base_y + r.ymin)
21525 if (y < base_y + r.ymax)
21529 base_y += r.baseline_y_delta;
21545 for (i=0; i < r.num_chars; ++i) {
21546 float w = nk_textedit_get_width(edit, k, i, font);
21547 if (x < prev_x+w) {
21548 if (x < prev_x+w/2)
21560 return i+r.num_chars-1;
21561 else return i+r.num_chars;
21564nk_textedit_click(
struct nk_text_edit *state,
float x,
float y,
21569 state->
cursor = nk_textedit_locate_coord(state, x, y, font, row_height);
21575nk_textedit_drag(
struct nk_text_edit *state,
float x,
float y,
21580 int p = nk_textedit_locate_coord(state, x, y, font, row_height);
21586nk_textedit_find_charpos(
struct nk_text_find *find,
struct nk_text_edit *state,
21587 int n,
int single_line,
const struct nk_user_font *font,
float row_height)
21591 struct nk_text_edit_row r;
21592 int prev_start = 0;
21600 nk_textedit_layout_row(&r, state, 0, row_height, font);
21602 find->first_char = 0;
21608 nk_textedit_layout_row(&r, state, i, row_height, font);
21611 find->first_char = i;
21612 find->length = r.num_chars;
21616 find->height = r.ymax - r.ymin;
21617 find->prev_first = prev_start;
21625 nk_textedit_layout_row(&r, state, i, row_height, font);
21626 if (n < i + r.num_chars)
break;
21629 find->y += r.baseline_y_delta;
21632 find->first_char = first = i;
21633 find->length = r.num_chars;
21634 find->height = r.ymax - r.ymin;
21635 find->prev_first = prev_start;
21639 for (i=0; first+i < n; ++i)
21640 find->x += nk_textedit_get_width(state, first, i, font);
21647 if (NK_TEXT_HAS_SELECTION(state)) {
21660 nk_textedit_makeundo_delete(state, where, len);
21668 nk_textedit_clamp(state);
21669 if (NK_TEXT_HAS_SELECTION(state)) {
21696 if (NK_TEXT_HAS_SELECTION(state)) {
21697 nk_textedit_sortselection(state);
21707 if (NK_TEXT_HAS_SELECTION(state)) {
21708 nk_textedit_sortselection(state);
21709 nk_textedit_clamp(state);
21716nk_is_word_boundary(
struct nk_text_edit *state,
int idx)
21720 if (idx <= 0)
return 1;
21722 return (c ==
' ' || c ==
'\t' ||c == 0x3000 || c ==
',' || c ==
';' ||
21723 c ==
'(' || c ==
')' || c ==
'{' || c ==
'}' || c ==
'[' || c ==
']' ||
21727nk_textedit_move_to_word_previous(
struct nk_text_edit *state)
21729 int c = state->
cursor - 1;
21730 while( c >= 0 && !nk_is_word_boundary(state, c))
21739nk_textedit_move_to_word_next(
struct nk_text_edit *state)
21742 int c = state->
cursor+1;
21743 while( c < len && !nk_is_word_boundary(state, c))
21752nk_textedit_prep_selection_at_cursor(
struct nk_text_edit *state)
21755 if (!NK_TEXT_HAS_SELECTION(state))
21765 if (NK_TEXT_HAS_SELECTION(state)) {
21777 const char *text = (
const char *) ctext;
21781 nk_textedit_clamp(state);
21787 nk_textedit_makeundo_insert(state, state->
cursor, glyphs);
21809 while ((text_len < total_len) && glyph_len)
21812 if (unicode == 127)
goto next;
21814 if (unicode ==
'\n' && state->
single_line)
goto next;
21816 if (state->
filter && !state->
filter(state, unicode))
goto next;
21818 if (!NK_TEXT_HAS_SELECTION(state) &&
21822 nk_textedit_makeundo_replace(state, state->
cursor, 1, 1);
21836 nk_textedit_makeundo_insert(state, state->
cursor, 1);
21842 text_len += glyph_len;
21843 glyph_len =
nk_utf_decode(text + text_len, &unicode, total_len-text_len);
21894 nk_textedit_clamp(state);
21895 nk_textedit_prep_selection_at_cursor(state);
21904 if (NK_TEXT_HAS_SELECTION(state))
21905 nk_textedit_move_to_first(state);
21906 else if (state->
cursor > 0)
21913 nk_textedit_prep_selection_at_cursor(state);
21916 nk_textedit_clamp(state);
21922 if (NK_TEXT_HAS_SELECTION(state))
21923 nk_textedit_move_to_last(state);
21925 nk_textedit_clamp(state);
21931 if( !NK_TEXT_HAS_SELECTION( state ) )
21932 nk_textedit_prep_selection_at_cursor(state);
21933 state->
cursor = nk_textedit_move_to_word_previous(state);
21935 nk_textedit_clamp(state );
21937 if (NK_TEXT_HAS_SELECTION(state))
21938 nk_textedit_move_to_first(state);
21940 state->
cursor = nk_textedit_move_to_word_previous(state);
21941 nk_textedit_clamp(state );
21947 if( !NK_TEXT_HAS_SELECTION( state ) )
21948 nk_textedit_prep_selection_at_cursor(state);
21949 state->
cursor = nk_textedit_move_to_word_next(state);
21951 nk_textedit_clamp(state);
21953 if (NK_TEXT_HAS_SELECTION(state))
21954 nk_textedit_move_to_last(state);
21956 state->
cursor = nk_textedit_move_to_word_next(state);
21957 nk_textedit_clamp(state );
21962 struct nk_text_find find;
21963 struct nk_text_edit_row row;
21964 int i, sel = shift_mod;
21973 nk_textedit_prep_selection_at_cursor(state);
21974 else if (NK_TEXT_HAS_SELECTION(state))
21975 nk_textedit_move_to_last(state);
21978 nk_textedit_clamp(state);
21987 int start = find.first_char + find.length;
21990 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
21993 for (i=0; i < row.num_chars && x < row.x1; ++i) {
21994 float dx = nk_textedit_get_width(state, start, i, font);
22000 nk_textedit_clamp(state);
22010 struct nk_text_find find;
22011 struct nk_text_edit_row row;
22012 int i, sel = shift_mod;
22021 nk_textedit_prep_selection_at_cursor(state);
22022 else if (NK_TEXT_HAS_SELECTION(state))
22023 nk_textedit_move_to_first(state);
22026 nk_textedit_clamp(state);
22031 if (find.prev_first != find.first_char) {
22036 state->
cursor = find.prev_first;
22037 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
22040 for (i=0; i < row.num_chars && x < row.x1; ++i) {
22041 float dx = nk_textedit_get_width(state, find.prev_first, i, font);
22047 nk_textedit_clamp(state);
22058 if (NK_TEXT_HAS_SELECTION(state))
22071 if (NK_TEXT_HAS_SELECTION(state))
22074 nk_textedit_clamp(state);
22075 if (state->
cursor > 0) {
22085 nk_textedit_prep_selection_at_cursor(state);
22096 nk_textedit_prep_selection_at_cursor(state);
22108 struct nk_text_find find;
22109 nk_textedit_clamp(state);
22110 nk_textedit_prep_selection_at_cursor(state);
22118 struct nk_text_find find;
22121 nk_textedit_clamp(state);
22122 nk_textedit_move_to_first(state);
22125 state->
cursor = find.first_char;
22132 struct nk_text_find find;
22133 nk_textedit_clamp(state);
22134 nk_textedit_prep_selection_at_cursor(state);
22138 state->
cursor = find.first_char + find.length;
22143 struct nk_text_find find;
22144 nk_textedit_clamp(state);
22145 nk_textedit_move_to_first(state);
22150 state->
cursor = find.first_char + find.length;
22220 nk_textedit_flush_redo(state);
22225 nk_textedit_discard_undo(state);
22238 nk_textedit_discard_undo(state);
22243 int insert_len,
int delete_len)
22253 if (insert_len == 0) {
22277 r->
where = u.where;
22279 if (u.delete_length)
22298 nk_textedit_discard_redo(s);
22309 for (i=0; i < u.delete_length; ++i)
22318 if (u.insert_length) {
22321 &s->
undo_char[u.char_storage], u.insert_length);
22324 state->
cursor = (short)(u.where + u.insert_length);
22381 nk_textedit_createundo(&state->
undo,
where, 0, length);
22389 for (i=0; i < length; ++i)
22395 int old_length,
int new_length)
22398 nk_rune *p = nk_textedit_createundo(&state->
undo,
where, old_length, new_length);
22400 for (i=0; i < old_length; ++i)
22429 if (!state || !memory || !size)
return;
22439 if (!state || !alloc)
return;
22444#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
22449 if (!state)
return;
22452 nk_str_init_default(&state->
string);
22466 if (!state)
return;
22489 if (unicode > 128)
return nk_false;
22496 if ((unicode < '0' || unicode >
'9') && unicode !=
'.' && unicode !=
'-')
22504 if ((unicode < '0' || unicode >
'9') && unicode !=
'-')
22512 if ((unicode < '0' || unicode >
'9') &&
22513 (unicode < 'a' || unicode >
'f') &&
22514 (unicode < 'A' || unicode >
'F'))
22522 if (unicode < '0' || unicode >
'7')
22530 if (unicode !=
'0' && unicode !=
'1')
22542 const struct nk_style_edit *style,
float pos_x,
float pos_y,
22543 float x_offset,
const char *text,
int byte_len,
float row_height,
22545 struct nk_color foreground,
int is_selected)
22550 if (!text || !byte_len || !out || !style)
return;
22552 {
int glyph_len = 0;
22555 float line_width = 0;
22557 const char *line = text;
22558 float line_offset = 0;
22559 int line_count = 0;
22563 txt.background = background;
22564 txt.text = foreground;
22566 glyph_len =
nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
22567 if (!glyph_len)
return;
22568 while ((text_len < byte_len) && glyph_len)
22570 if (unicode ==
'\n') {
22573 label.
y = pos_y + line_offset;
22574 label.h = row_height;
22575 label.w = line_width;
22578 label.x += x_offset;
22582 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
22588 line = text + text_len;
22589 line_offset += row_height;
22590 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)(byte_len-text_len));
22593 if (unicode ==
'\r') {
22595 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
22599 line_width += (float)glyph_width;
22600 text_len += glyph_len;
22601 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
22604 if (line_width > 0) {
22607 label.
y = pos_y + line_offset;
22608 label.h = row_height;
22609 label.w = line_width;
22612 label.x += x_offset;
22616 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
22629 char prev_state = 0;
22630 char is_hovered = 0;
22631 char select_all = 0;
22632 char cursor_follow = 0;
22639 if (!state || !out || !style)
22652 old_clip = out->
clip;
22653 nk_unify(&clip, &old_clip, area.x, area.y, area.x + area.w, area.y + area.h);
22656 prev_state = (char)edit->
active;
22660 bounds.
x, bounds.
y, bounds.
w, bounds.
h);
22664 if (!prev_state && edit->
active) {
22667 nk_textedit_clear_state(edit, type, filter);
22681 if (prev_state != edit->
active)
22697 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
22700 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
22710 int old_mode = edit->
mode;
22714 nk_textedit_key(edit, (
enum nk_keys)i, shift_mod, font, row_height);
22718 if (old_mode != edit->
mode) {
22751 int begin =
NK_MIN(b, e);
22780 else nk_widget_state_reset(state);
22792 background = &style->
active;
22794 background = &style->
hover;
22795 else background = &style->
normal;
22806 int total_lines = 1;
22810 const char *cursor_ptr = 0;
22811 const char *select_begin_ptr = 0;
22812 const char *select_end_ptr = 0;
22823 float line_width = 0.0f;
22839 while ((text_len < len) && glyph_len)
22842 if (!cursor_ptr && glyphs == edit->
cursor)
22847 const char *remaining;
22850 cursor_pos.
y = (float)(total_lines-1) * row_height;
22851 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
22852 text_len-row_begin, row_height, &remaining,
22853 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
22854 cursor_pos.
x = row_size.x;
22855 cursor_ptr = text + text_len;
22860 glyphs == selection_begin)
22865 const char *remaining;
22868 selection_offset_start.
y = (float)(
NK_MAX(total_lines-1,0)) * row_height;
22869 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
22870 text_len-row_begin, row_height, &remaining,
22871 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
22872 selection_offset_start.
x = row_size.x;
22873 select_begin_ptr = text + text_len;
22878 glyphs == selection_end)
22883 const char *remaining;
22886 selection_offset_end.
y = (float)(total_lines-1) * row_height;
22887 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
22888 text_len-row_begin, row_height, &remaining,
22889 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
22890 selection_offset_end.
x = row_size.x;
22891 select_end_ptr = text + text_len;
22893 if (unicode ==
'\n') {
22894 text_size.
x =
NK_MAX(text_size.
x, line_width);
22899 row_begin = text_len;
22900 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
22906 text_len += glyph_len;
22907 line_width += (float)glyph_width;
22909 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
22911 text+text_len, glyph_len);
22914 text_size.
y = (float)total_lines * row_height;
22918 cursor_pos.
x = line_width;
22919 cursor_pos.
y = text_size.
y - row_height;
22929 const float scroll_increment = area.w * 0.25f;
22950 float scroll_target;
22951 float scroll_offset;
22960 scroll_step = scroll.
h * 0.10f;
22961 scroll_inc = scroll.
h * 0.01f;
22962 scroll_target = text_size.
y;
22963 edit->
scrollbar.
y = nk_do_scrollbarv(&ws, out, scroll, 0,
22964 scroll_offset, scroll_target, scroll_step, scroll_inc,
22970 {
struct nk_color background_color;
22972 struct nk_color sel_background_color;
22975 struct nk_color cursor_text_color;
22981 background = &style->
active;
22988 background = &style->
hover;
22995 background = &style->
normal;
23003 background_color =
nk_rgba(0,0,0,0);
23004 else background_color = background->
data.
color;
23011 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
23012 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
23013 background_color, text_color,
nk_false);
23019 NK_ASSERT(select_begin_ptr);
23020 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
23021 area.y - edit->
scrollbar.
y, 0, begin, (
int)(select_begin_ptr - begin),
23022 row_height, font, background_color, text_color,
nk_false);
23026 NK_ASSERT(select_begin_ptr);
23027 if (!select_end_ptr) {
23031 nk_edit_draw_text(out, style,
23033 area.y + selection_offset_start.
y - edit->
scrollbar.
y,
23034 selection_offset_start.
x,
23035 select_begin_ptr, (
int)(select_end_ptr - select_begin_ptr),
23036 row_height, font, sel_background_color, sel_text_color,
nk_true);
23039 selection_end < edit->
string.len))
23042 const char *begin = select_end_ptr;
23045 NK_ASSERT(select_end_ptr);
23046 nk_edit_draw_text(out, style,
23048 area.y + selection_offset_end.
y - edit->
scrollbar.
y,
23049 selection_offset_end.
x,
23050 begin, (
int)(end - begin), row_height, font,
23051 background_color, text_color,
nk_true);
23059 (cursor_ptr && *cursor_ptr ==
'\n')) {
23063 cursor.h = font->
height;
23064 cursor.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
23065 cursor.y = area.y + cursor_pos.
y + row_height/2.0f - cursor.h/2.0f;
23075 NK_ASSERT(cursor_ptr);
23078 label.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
23079 label.y = area.y + cursor_pos.
y - edit->
scrollbar.
y;
23081 label.h = row_height;
23084 txt.background = cursor_color;;
23085 txt.text = cursor_text_color;
23087 nk_widget_text(out, label, cursor_ptr, glyph_len, &txt,
NK_TEXT_LEFT, font);
23100 background = &style->
active;
23103 background = &style->
hover;
23106 background = &style->
normal;
23110 background_color =
nk_rgba(0,0,0,0);
23111 else background_color = background->
data.
color;
23112 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
23113 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
23114 background_color, text_color,
nk_false);
23127 if (!ctx || !ctx->
current)
return;
23142 if (!ctx || !ctx->
current)
return;
23160 if (!ctx || !memory || !len)
23188 *len =
NK_MIN(*len, max-1);
23193 *len = (int)
edit->string.buffer.allocated;
23216 unsigned char prev_state;
23228 style = &ctx->
style;
23230 if (!state)
return state;
23249 prev_state = (
unsigned char)edit->
active;
23252 filter, edit, &style->
edit, in, style->
font);
23260 }
else if (prev_state && !edit->
active) {
23263 }
return ret_flags;
23286 struct nk_rect drag,
struct nk_property_variant *variant,
23287 float inc_per_pixel)
23290 int left_mouse_click_in_cursor = in &&
23293 nk_widget_state_reset(state);
23297 if (left_mouse_down && left_mouse_click_in_cursor) {
23298 float delta, pixels;
23300 delta = pixels * inc_per_pixel;
23301 switch (variant->kind) {
23303 case NK_PROPERTY_INT:
23304 variant->value.i = variant->value.i + (int)delta;
23305 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
23307 case NK_PROPERTY_FLOAT:
23308 variant->value.f = variant->value.f + (float)delta;
23309 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
23311 case NK_PROPERTY_DOUBLE:
23312 variant->value.d = variant->value.d + (double)delta;
23313 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
23326 struct nk_rect empty,
int *state,
struct nk_property_variant *variant,
23327 float inc_per_pixel)
23329 if (in && *state == NK_PROPERTY_DEFAULT) {
23331 *state = NK_PROPERTY_EDIT;
23333 *state = NK_PROPERTY_DRAG;
23335 *state = NK_PROPERTY_DRAG;
23337 if (*state == NK_PROPERTY_DRAG) {
23338 nk_drag_behavior(ws, in, property, variant, inc_per_pixel);
23345 const char *name,
int len,
const struct nk_user_font *font)
23352 background = &style->
active;
23355 background = &style->
hover;
23358 background = &style->
normal;
23365 text.background =
nk_rgba(0,0,0,0);
23367 text.background = background->
data.
color;
23379 const char *name,
struct nk_property_variant *variant,
23380 float inc_per_pixel,
char *buffer,
int *len,
23381 int *state,
int *cursor,
int *select_begin,
int *select_end,
23383 enum nk_property_filter filter,
struct nk_input *in,
23392 int num_len, name_len;
23409 left.y =
property.y + style->
border +
property.h/2.0f - left.h/2;
23414 label.
x = left.x + left.w + style->
padding.
x;
23415 label.
w = (float)size + 2 * style->
padding.
x;
23423 right.x =
property.x +
property.w - (right.w + style->
padding.
x);
23426 if (*state == NK_PROPERTY_EDIT) {
23432 switch (variant->kind) {
23434 case NK_PROPERTY_INT:
23435 nk_itoa(
string, variant->value.i);
23438 case NK_PROPERTY_FLOAT:
23439 NK_DTOA(
string, (
double)variant->value.f);
23442 case NK_PROPERTY_DOUBLE:
23443 NK_DTOA(
string, variant->value.d);
23452 edit.
w = (float)size + 2 * style->
padding.
x;
23453 edit.
w =
NK_MIN(edit.
w, right.x - (label.
x + label.
w));
23454 edit.
x = right.x - (edit.
w + style->
padding.
x);
23455 edit.
y =
property.y + style->
border;
23456 edit.
h =
property.h - (2 * style->
border);
23459 empty.
w = edit.
x - (label.
x + label.
w);
23460 empty.
x = label.
x + label.
w;
23461 empty.
y =
property.y;
23462 empty.
h =
property.h;
23465 old = (*state == NK_PROPERTY_EDIT);
23466 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
23470 nk_draw_property(out, style, &property, &label, *ws, name, name_len, font);
23474 if (nk_do_button_symbol(ws, out, left, style->
sym_left, behavior, &style->
dec_button, in, font)) {
23475 switch (variant->kind) {
23477 case NK_PROPERTY_INT:
23478 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i - variant->step.i, variant->max_value.i);
break;
23479 case NK_PROPERTY_FLOAT:
23480 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f - variant->step.f, variant->max_value.f);
break;
23481 case NK_PROPERTY_DOUBLE:
23482 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d - variant->step.d, variant->max_value.d);
break;
23486 if (nk_do_button_symbol(ws, out, right, style->
sym_right, behavior, &style->
inc_button, in, font)) {
23487 switch (variant->kind) {
23489 case NK_PROPERTY_INT:
23490 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i + variant->step.i, variant->max_value.i);
break;
23491 case NK_PROPERTY_FLOAT:
23492 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f + variant->step.f, variant->max_value.f);
break;
23493 case NK_PROPERTY_DOUBLE:
23494 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d + variant->step.d, variant->max_value.d);
break;
23497 if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) {
23499 NK_MEMCPY(buffer, dst, (
nk_size)*length);
23505 }
else active = (*state == NK_PROPERTY_EDIT);
23509 text_edit->
active = (
unsigned char)active;
23520 filters[filter], text_edit, &style->
edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
23523 *cursor = text_edit->
cursor;
23529 if (active && !text_edit->
active) {
23531 *state = NK_PROPERTY_DEFAULT;
23532 buffer[*len] =
'\0';
23533 switch (variant->kind) {
23535 case NK_PROPERTY_INT:
23536 variant->value.i =
nk_strtoi(buffer, 0);
23537 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
23539 case NK_PROPERTY_FLOAT:
23541 variant->value.f =
nk_strtof(buffer, 0);
23542 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
23544 case NK_PROPERTY_DOUBLE:
23546 variant->value.d =
nk_strtod(buffer, 0);
23547 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
23552NK_LIB struct nk_property_variant
23553nk_property_variant_int(int value, int min_value, int max_value, int step)
23555 struct nk_property_variant result;
23556 result.kind = NK_PROPERTY_INT;
23557 result.value.i = value;
23558 result.min_value.i = min_value;
23559 result.max_value.i = max_value;
23560 result.step.i = step;
23563NK_LIB struct nk_property_variant
23564nk_property_variant_float(float value, float min_value, float max_value, float step)
23566 struct nk_property_variant result;
23567 result.kind = NK_PROPERTY_FLOAT;
23568 result.value.f = value;
23569 result.min_value.f = min_value;
23570 result.max_value.f = max_value;
23571 result.step.f = step;
23574NK_LIB struct nk_property_variant
23575nk_property_variant_double(double value, double min_value, double max_value,
23578 struct nk_property_variant result;
23579 result.kind = NK_PROPERTY_DOUBLE;
23580 result.value.d = value;
23581 result.min_value.d = min_value;
23582 result.max_value.d = max_value;
23583 result.step.d = step;
23587nk_property(
struct nk_context *ctx,
const char *name,
struct nk_property_variant *variant,
23588 float inc_per_pixel,
const enum nk_property_filter filter)
23603 int *select_begin = 0;
23604 int *select_end = 0;
23608 int dummy_state = NK_PROPERTY_DEFAULT;
23609 int dummy_length = 0;
23610 int dummy_cursor = 0;
23611 int dummy_select_begin = 0;
23612 int dummy_select_end = 0;
23622 style = &ctx->
style;
23627 if (name[0] ==
'#') {
23641 buffer = dummy_buffer;
23642 len = &dummy_length;
23643 cursor = &dummy_cursor;
23644 state = &dummy_state;
23645 select_begin = &dummy_select_begin;
23646 select_end = &dummy_select_end;
23650 old_state = *state;
23655 variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
23659 if (in && *state != NK_PROPERTY_DEFAULT && !win->
property.
active) {
23669 if (*state == NK_PROPERTY_DRAG) {
23675 if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {
23676 if (old_state == NK_PROPERTY_DRAG) {
23688 int min,
int *val,
int max,
int step,
float inc_per_pixel)
23690 struct nk_property_variant variant;
23695 if (!ctx || !ctx->
current || !name || !val)
return;
23696 variant = nk_property_variant_int(*val, min, max, step);
23697 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
23698 *val = variant.value.i;
23702 float min,
float *val,
float max,
float step,
float inc_per_pixel)
23704 struct nk_property_variant variant;
23709 if (!ctx || !ctx->
current || !name || !val)
return;
23710 variant = nk_property_variant_float(*val, min, max, step);
23711 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23712 *val = variant.value.f;
23716 double min,
double *val,
double max,
double step,
float inc_per_pixel)
23718 struct nk_property_variant variant;
23723 if (!ctx || !ctx->
current || !name || !val)
return;
23724 variant = nk_property_variant_double(*val, min, max, step);
23725 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23726 *val = variant.value.d;
23730 int max,
int step,
float inc_per_pixel)
23732 struct nk_property_variant variant;
23736 if (!ctx || !ctx->
current || !name)
return val;
23737 variant = nk_property_variant_int(val, min, max, step);
23738 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
23739 val = variant.value.i;
23744 float val,
float max,
float step,
float inc_per_pixel)
23746 struct nk_property_variant variant;
23750 if (!ctx || !ctx->
current || !name)
return val;
23751 variant = nk_property_variant_float(val, min, max, step);
23752 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23753 val = variant.value.f;
23758 double val,
double max,
double step,
float inc_per_pixel)
23760 struct nk_property_variant variant;
23764 if (!ctx || !ctx->
current || !name)
return val;
23765 variant = nk_property_variant_double(val, min, max, step);
23766 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23767 val = variant.value.d;
23782 int count,
float min_value,
float max_value)
23790 struct nk_rect bounds = {0, 0, 0, 0};
23799 nk_zero(chart,
sizeof(*chart));
23804 config = &ctx->
style;
23806 style = &config->
chart;
23809 nk_zero(chart,
sizeof(*chart));
23823 slot->
min =
NK_MIN(min_value, max_value);
23824 slot->
max =
NK_MAX(min_value, max_value);
23840 int count,
float min_value,
float max_value)
23848 int count,
float min_value,
float max_value)
23864 slot->
min =
NK_MIN(min_value, max_value);
23865 slot->
max =
NK_MAX(min_value, max_value);
23870 int count,
float min_value,
float max_value)
23877 struct nk_chart *g,
float value,
int slot)
23892 step =
g->w / (float)
g->slots[slot].count;
23893 range =
g->slots[slot].max -
g->slots[slot].min;
23894 ratio = (value -
g->slots[slot].min) / range;
23896 if (
g->slots[slot].index == 0) {
23898 g->slots[slot].last.x =
g->x;
23899 g->slots[slot].last.y = (
g->y +
g->h) - ratio * (
float)
g->h;
23901 bounds.
x =
g->slots[slot].last.x - 2;
23902 bounds.
y =
g->slots[slot].last.y - 2;
23903 bounds.
w = bounds.
h = 4;
23905 color =
g->slots[slot].color;
23911 color =
g->slots[slot].highlight;
23914 g->slots[slot].index += 1;
23919 color =
g->slots[slot].color;
23920 cur.x =
g->x + (float)(step * (
float)
g->slots[slot].index);
23921 cur.y = (
g->y +
g->h) - (ratio * (
float)
g->h);
23922 nk_stroke_line(out,
g->slots[slot].last.x,
g->slots[slot].last.y, cur.x, cur.y, 1.0f, color);
23924 bounds.
x = cur.x - 3;
23925 bounds.
y = cur.y - 3;
23926 bounds.
w = bounds.
h = 6;
23934 color =
g->slots[slot].highlight;
23940 g->slots[slot].last.x = cur.x;
23941 g->slots[slot].last.y = cur.y;
23942 g->slots[slot].index += 1;
23947 struct nk_chart *chart,
float value,
int slot)
23956 struct nk_rect item = {0,0,0,0};
23962 float padding = (float)(chart->
slots[slot].
count-1);
23963 item.
w = (chart->
w - padding) / (
float)(chart->
slots[slot].
count);
23971 item.
y = (chart->
y + chart->
h) - chart->
h * ratio;
23974 item.
y = chart->
y + (chart->
h *
NK_ABS(ratio)) - item.
h;
23976 item.
x = chart->
x + ((float)chart->
slots[slot].
index * item.
w);
24000 NK_ASSERT(slot < ctx->current->layout->chart.slot);
24008 flags = nk_chart_push_line(ctx, win, &win->
layout->
chart, value, slot);
break;
24010 flags = nk_chart_push_column(ctx, win, &win->
layout->
chart, value, slot);
break;
24035 NK_MEMSET(chart, 0,
sizeof(*chart));
24040 int count,
int offset)
24048 if (!ctx || !values || !count)
return;
24050 min_value = values[offset];
24051 max_value = values[offset];
24052 for (i = 0; i < count; ++i) {
24053 min_value =
NK_MIN(values[i + offset], min_value);
24054 max_value =
NK_MAX(values[i + offset], max_value);
24058 for (i = 0; i < count; ++i)
24065 float(*value_getter)(
void* user,
int index),
int count,
int offset)
24072 NK_ASSERT(value_getter);
24073 if (!ctx || !value_getter || !count)
return;
24075 max_value = min_value = value_getter(userdata, offset);
24076 for (i = 0; i < count; ++i) {
24077 float value = value_getter(userdata, i + offset);
24078 min_value =
NK_MIN(value, min_value);
24079 max_value =
NK_MAX(value, max_value);
24083 for (i = 0; i < count; ++i)
24098nk_color_picker_behavior(
nk_flags *state,
24104 int value_changed = 0;
24105 int hsv_changed = 0;
24109 NK_ASSERT(hue_bar);
24117 value_changed = hsv_changed = 1;
24122 value_changed = hsv_changed = 1;
24131 nk_widget_state_reset(state);
24136 if (value_changed) {
24137 color->
a = hsva[3];
24147 return value_changed;
24158 const float crosshair_size = 7.0f;
24166 NK_ASSERT(hue_bar);
24170 for (i = 0; i < 6; ++i) {
24172 {255, 0, 0, 255}, {255,255,0,255}, {0,255,0,255}, {0, 255,255,255},
24173 {0,0,255,255}, {255, 0, 255, 255}, {255, 0, 0, 255}
24176 nk_rect(hue_bar->
x, hue_bar->
y + (
float)i * (hue_bar->
h/6.0f) + 0.5f,
24177 hue_bar->
w, (hue_bar->
h/6.0f) + 0.5f), hue_colors[i], hue_colors[i],
24178 hue_colors[i+1], hue_colors[i+1]);
24180 line_y = (float)(
int)(hue_bar->
y + hsva[0] * matrix->
h + 0.5f);
24182 line_y, 1,
nk_rgb(255,255,255));
24187 line_y = (float)(
int)(alpha_bar->
y + (1.0f - alpha) * matrix->
h + 0.5f);
24191 line_y, 1,
nk_rgb(255,255,255));
24195 temp =
nk_hsv_f(hsva[0], 1.0f, 1.0f);
24200 {
struct nk_vec2 p;
float S = hsva[1];
float V = hsva[2];
24201 p.
x = (float)(
int)(matrix->
x + S * matrix->
w);
24202 p.y = (float)(
int)(matrix->
y + (1.0f - V) * matrix->
h);
24203 nk_stroke_line(o, p.x - crosshair_size, p.y, p.x-2, p.y, 1.0f, white);
24204 nk_stroke_line(o, p.x + crosshair_size + 1, p.y, p.x+3, p.y, 1.0f, white);
24205 nk_stroke_line(o, p.x, p.y + crosshair_size + 1, p.x, p.y+3, 1.0f, white);
24206 nk_stroke_line(o, p.x, p.y - crosshair_size, p.x, p.y-2, 1.0f, white);}
24209nk_do_color_picker(
nk_flags *state,
24225 if (!out || !col || !state || !font)
24229 bounds.
x += padding.
x;
24230 bounds.
y += padding.
x;
24231 bounds.
w -= 2 * padding.
x;
24232 bounds.
h -= 2 * padding.
y;
24234 matrix.
x = bounds.
x;
24235 matrix.
y = bounds.
y;
24236 matrix.
h = bounds.
h;
24237 matrix.
w = bounds.
w - (3 * padding.
x + 2 * bar_w);
24240 hue_bar.
y = bounds.
y;
24241 hue_bar.
h = matrix.
h;
24242 hue_bar.
x = matrix.
x + matrix.
w + padding.
x;
24244 alpha_bar.
x = hue_bar.
x + hue_bar.
w + padding.
x;
24245 alpha_bar.
y = bounds.
y;
24246 alpha_bar.
w = bar_w;
24247 alpha_bar.
h = matrix.
h;
24249 ret = nk_color_picker_behavior(state, &bounds, &matrix, &hue_bar,
24250 (fmt ==
NK_RGBA) ? &alpha_bar:0, col, in);
24251 nk_draw_color_picker(out, &matrix, &hue_bar, (fmt ==
NK_RGBA) ? &alpha_bar:0, *col);
24274 config = &ctx->
style;
24277 if (!state)
return 0;
24323 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
24324 (!is_open && !is_active && !is_clicked))
return 0;
24325 if (!nk_nonblock_begin(ctx, 0, body,
24347 NK_ASSERT(selected);
24354 style = &ctx->
style;
24375 text.background =
nk_rgba(0,0,0,0);
24378 text.background = background->
data.
color;
24391 else if (is_clicked)
24399 button.h = button.w;
24412 nk_widget_text(&win->
buffer, label, selected, len, &text,
24419 return nk_combo_begin(ctx, win, size, is_clicked, header);
24445 style = &ctx->
style;
24475 else if (is_clicked)
24483 button.h = button.w;
24501 return nk_combo_begin(ctx, win, size, is_clicked, header);
24524 style = &ctx->
style;
24546 sym_background =
nk_rgba(0,0,0,0);
24549 sym_background = background->
data.
color;
24554 struct nk_rect bounds = {0,0,0,0};
24561 else if (is_clicked)
24569 button.h = button.w;
24581 nk_draw_symbol(&win->
buffer, symbol, bounds, sym_background, symbol_color,
24582 1.0f, style->
font);
24588 return nk_combo_begin(ctx, win, size, is_clicked, header);
24612 style = &ctx->
style;
24635 text.background =
nk_rgba(0,0,0,0);
24638 text.background = background->
data.
color;
24651 else if (is_clicked)
24659 button.h = button.w;
24673 nk_draw_symbol(&win->
buffer, symbol, image, text.background, symbol_color,
24674 1.0f, style->
font);
24684 return nk_combo_begin(ctx, win, size, is_clicked, header);
24705 style = &ctx->
style;
24728 struct nk_rect bounds = {0,0,0,0};
24735 else if (is_clicked)
24743 button.h = button.w;
24761 return nk_combo_begin(ctx, win, size, is_clicked, header);
24784 style = &ctx->
style;
24804 text.background =
nk_rgba(0,0,0,0);
24807 text.background = background->
data.
color;
24820 else if (is_clicked)
24828 button.h = button.w;
24852 return nk_combo_begin(ctx, win, size, is_clicked, header);
24884 const char *text,
nk_flags alignment)
24890 const char *text,
int len,
nk_flags alignment)
24896 const char *label,
nk_flags alignment)
24910 int selected,
int item_height,
struct nk_vec2 size)
24915 struct nk_vec2 window_padding;
24920 if (!ctx || !items ||!count)
24925 max_height = count * item_height + count * (int)item_spacing.y;
24926 max_height += (
int)item_spacing.y * 2 + (int)window_padding.y * 2;
24927 size.
y =
NK_MIN(size.
y, (
float)max_height);
24930 for (i = 0; i < count; ++i) {
24940 int separator,
int selected,
int count,
int item_height,
struct nk_vec2 size)
24945 struct nk_vec2 window_padding;
24946 const char *current_item;
24951 NK_ASSERT(items_separated_by_separator);
24952 if (!ctx || !items_separated_by_separator)
24958 max_height = count * item_height + count * (int)item_spacing.y;
24959 max_height += (
int)item_spacing.y * 2 + (int)window_padding.y * 2;
24960 size.
y =
NK_MIN(size.
y, (
float)max_height);
24963 current_item = items_separated_by_separator;
24964 for (i = 0; i < count; ++i) {
24965 iter = current_item;
24966 while (*iter && *iter != separator) iter++;
24967 length = (int)(iter - current_item);
24968 if (i == selected)
break;
24969 current_item = iter + 1;
24973 current_item = items_separated_by_separator;
24975 for (i = 0; i < count; ++i) {
24976 iter = current_item;
24977 while (*iter && *iter != separator) iter++;
24978 length = (int)(iter - current_item);
24981 current_item = current_item + length + 1;
24989 int selected,
int count,
int item_height,
struct nk_vec2 size)
24991 return nk_combo_separator(ctx, items_separated_by_zeros,
'\0', selected, count, item_height, size);
24995 void *userdata,
int selected,
int count,
int item_height,
struct nk_vec2 size)
25000 struct nk_vec2 window_padding;
25004 NK_ASSERT(item_getter);
25005 if (!ctx || !item_getter)
25011 max_height = count * item_height + count * (int)item_spacing.y;
25012 max_height += (
int)item_spacing.y * 2 + (int)window_padding.y * 2;
25013 size.
y =
NK_MIN(size.
y, (
float)max_height);
25015 item_getter(userdata, selected, &item);
25018 for (i = 0; i < count; ++i) {
25019 item_getter(userdata, i, &item);
25028 int *selected,
int item_height,
struct nk_vec2 size)
25030 *selected =
nk_combo(ctx, items, count, *selected, item_height, size);
25034 int *selected,
int count,
int item_height,
struct nk_vec2 size)
25036 *selected =
nk_combo_string(ctx, items_separated_by_zeros, *selected, count, item_height, size);
25040 int separator,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
25043 *selected, count, item_height, size);
25047 void(*item_getter)(
void* data,
int id,
const char **out_text),
25048 void *userdata,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
25050 *selected =
nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);
25082 w = nk_iceilf(width);
25083 h = nk_iceilf(nk_null_rect.h);
25087 bounds.
x = (
float)
x;
25088 bounds.
y = (float)
y;
25089 bounds.
w = (float)
w;
25090 bounds.
h = (float)
h;
25105 if (!ctx || !ctx->
current)
return;
25128 style = &ctx->
style;
25135 text_width += (4 * padding.
x);
25136 text_height = (style->
font->
height + 2 * padding.
y);
25145#ifdef NK_INCLUDE_STANDARD_VARARGS
25147nk_tooltipf(
struct nk_context *ctx,
const char *fmt, ...)
25150 va_start(args, fmt);
25151 nk_tooltipfv(ctx, fmt, args);
25155nk_tooltipfv(
struct nk_context *ctx,
const char *fmt, va_list args)
25158 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color)
NK_API struct nk_rect nk_window_get_content_region(struct nk_context *)
NK_API struct nk_window * nk_window_find(struct nk_context *ctx, const char *name)
void(* nk_plugin_copy)(nk_handle, const char *, int len)
Definition: nuklear.h:269
#define NK_VECTOR_STACK_SIZE
Definition: nuklear.h:5260
NK_API const char * nk_str_at_const(const struct nk_str *, int pos, nk_rune *unicode, int *len)
NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a)
NK_API void nk_str_free(struct nk_str *)
NK_API char * nk_str_at_char(struct nk_str *, int pos)
NK_API int nk_combo_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API void nk_tree_pop(struct nk_context *)
NK_API struct nk_color nk_hsva_iv(const int *hsva)
NK_API struct nk_rect nk_layout_space_bounds(struct nk_context *)
NK_API struct nk_color nk_rgb(int r, int g, int b)
NK_API void nk_free(struct nk_context *)
@ nk_true
Definition: nuklear.h:239
@ nk_false
Definition: nuklear.h:239
NK_API void nk_str_delete_runes(struct nk_str *, int pos, int len)
NK_API void nk_stroke_rect(struct nk_command_buffer *, struct nk_rect, float rounding, float line_thickness, struct nk_color)
NK_API void nk_property_int(struct nk_context *, const char *name, int min, int *val, int max, int step, float inc_per_pixel)
NK_INT8 nk_char
Definition: nuklear.h:181
NK_API nk_size nk_buffer_total(struct nk_buffer *)
NK_API float nk_widget_width(struct nk_context *)
#define NK_API
Definition: nuklear.h:45
NK_API int nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags)
#define NK_FLAG(x)
Definition: nuklear.h:60
NK_API void nk_buffer_mark(struct nk_buffer *, enum nk_buffer_allocation_type type)
NK_API nk_handle nk_handle_ptr(void *)
NK_API void nk_combobox_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_contextual_item_text(struct nk_context *, const char *, int, nk_flags align)
NK_API int nk_combo_begin_image_label(struct nk_context *, const char *selected, struct nk_image, struct nk_vec2 size)
NK_API nk_uint nk_color_u32(struct nk_color)
NK_API struct nk_image nk_image_handle(nk_handle)
NK_API void nk_menu_close(struct nk_context *)
NK_API int nk_item_is_any_active(struct nk_context *)
NK_API void nk_color_dv(double *rgba_out, struct nk_color)
NK_API int nk_selectable_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags align, int *value)
NK_API void nk_image(struct nk_context *, struct nk_image)
#define NK_CONTAINER_OF(ptr, type, member)
Definition: nuklear.h:5445
NK_API struct nk_rect nk_get_null_rect(void)
NK_API int nk_slide_int(struct nk_context *, int min, int val, int max, int step)
NK_API struct nk_color nk_hsv_iv(const int *hsv)
NK_API int nk_input_is_key_pressed(const struct nk_input *, enum nk_keys)
#define NK_STORAGE
Definition: nuklear.h:57
NK_API void nk_layout_row_end(struct nk_context *)
NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context *)
NK_API void nk_input_end(struct nk_context *)
NK_API void nk_menu_end(struct nk_context *)
NK_API int nk_check_label(struct nk_context *, const char *, int active)
nk_keys
Definition: nuklear.h:518
@ NK_KEY_LEFT
Definition: nuklear.h:531
@ NK_KEY_TEXT_SELECT_ALL
Definition: nuklear.h:543
@ NK_KEY_TEXT_WORD_LEFT
Definition: nuklear.h:544
@ NK_KEY_TEXT_REPLACE_MODE
Definition: nuklear.h:535
@ NK_KEY_TEXT_REDO
Definition: nuklear.h:542
@ NK_KEY_UP
Definition: nuklear.h:529
@ NK_KEY_TEXT_END
Definition: nuklear.h:540
@ NK_KEY_TEXT_UNDO
Definition: nuklear.h:541
@ NK_KEY_TEXT_RESET_MODE
Definition: nuklear.h:536
@ NK_KEY_DEL
Definition: nuklear.h:522
@ NK_KEY_NONE
Definition: nuklear.h:519
@ NK_KEY_SCROLL_END
Definition: nuklear.h:548
@ NK_KEY_CTRL
Definition: nuklear.h:521
@ NK_KEY_MAX
Definition: nuklear.h:551
@ NK_KEY_TEXT_LINE_START
Definition: nuklear.h:537
@ NK_KEY_TEXT_INSERT_MODE
Definition: nuklear.h:534
@ NK_KEY_COPY
Definition: nuklear.h:526
@ NK_KEY_SCROLL_UP
Definition: nuklear.h:550
@ NK_KEY_RIGHT
Definition: nuklear.h:532
@ NK_KEY_TAB
Definition: nuklear.h:524
@ NK_KEY_PASTE
Definition: nuklear.h:528
@ NK_KEY_SHIFT
Definition: nuklear.h:520
@ NK_KEY_TEXT_LINE_END
Definition: nuklear.h:538
@ NK_KEY_ENTER
Definition: nuklear.h:523
@ NK_KEY_TEXT_WORD_RIGHT
Definition: nuklear.h:545
@ NK_KEY_BACKSPACE
Definition: nuklear.h:525
@ NK_KEY_SCROLL_DOWN
Definition: nuklear.h:549
@ NK_KEY_DOWN
Definition: nuklear.h:530
@ NK_KEY_CUT
Definition: nuklear.h:527
@ NK_KEY_SCROLL_START
Definition: nuklear.h:547
@ NK_KEY_TEXT_START
Definition: nuklear.h:539
#define nk_vec2_add(a, b)
Definition: nuklear.h:5413
NK_API int nk_button_text_styled(struct nk_context *, const struct nk_style_button *, const char *title, int len)
NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name)
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
nk_edit_flags
Definition: nuklear.h:3198
@ NK_EDIT_MULTILINE
Definition: nuklear.h:3210
@ NK_EDIT_NO_HORIZONTAL_SCROLL
Definition: nuklear.h:3208
@ NK_EDIT_ALWAYS_INSERT_MODE
Definition: nuklear.h:3209
@ NK_EDIT_SIG_ENTER
Definition: nuklear.h:3202
@ NK_EDIT_READ_ONLY
Definition: nuklear.h:3200
@ NK_EDIT_AUTO_SELECT
Definition: nuklear.h:3201
@ NK_EDIT_CLIPBOARD
Definition: nuklear.h:3206
@ NK_EDIT_SELECTABLE
Definition: nuklear.h:3205
@ NK_EDIT_NO_CURSOR
Definition: nuklear.h:3204
@ NK_EDIT_ALLOW_TAB
Definition: nuklear.h:3203
@ NK_EDIT_DEFAULT
Definition: nuklear.h:3199
@ NK_EDIT_GOTO_END_ON_ACTIVATE
Definition: nuklear.h:3211
@ NK_EDIT_CTRL_ENTER_NEWLINE
Definition: nuklear.h:3207
NK_API int nk_tree_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
NK_API int nk_slider_int(struct nk_context *, int min, int *val, int max, int step)
NK_API struct nk_vec2 nk_vec2iv(const int *xy)
NK_API struct nk_color nk_rgba_hex(const char *rgb)
NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color)
NK_API void nk_input_key(struct nk_context *, enum nk_keys, int down)
NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color)
nk_uint nk_flags
Definition: nuklear.h:192
#define NK_ALIGNOF(t)
Definition: nuklear.h:5462
NK_UINT8 nk_byte
Definition: nuklear.h:183
NK_API void nk_popup_set_scroll(struct nk_context *, nk_uint offset_x, nk_uint offset_y)
nk_convert_result
Definition: nuklear.h:926
@ NK_CONVERT_COMMAND_BUFFER_FULL
Definition: nuklear.h:929
@ NK_CONVERT_VERTEX_BUFFER_FULL
Definition: nuklear.h:930
@ NK_CONVERT_SUCCESS
Definition: nuklear.h:927
@ NK_CONVERT_INVALID_PARAM
Definition: nuklear.h:928
@ NK_CONVERT_ELEMENT_BUFFER_FULL
Definition: nuklear.h:931
NK_API float nk_window_get_width(const struct nk_context *)
NK_API int nk_button_image_label(struct nk_context *, struct nk_image img, const char *, nk_flags text_alignment)
nk_panel_row_layout_type
Definition: nuklear.h:5067
@ NK_LAYOUT_DYNAMIC
Definition: nuklear.h:5071
@ NK_LAYOUT_COUNT
Definition: nuklear.h:5077
@ NK_LAYOUT_DYNAMIC_ROW
Definition: nuklear.h:5069
@ NK_LAYOUT_STATIC_ROW
Definition: nuklear.h:5073
@ NK_LAYOUT_STATIC
Definition: nuklear.h:5075
@ NK_LAYOUT_STATIC_FREE
Definition: nuklear.h:5074
@ NK_LAYOUT_DYNAMIC_FIXED
Definition: nuklear.h:5068
@ NK_LAYOUT_TEMPLATE
Definition: nuklear.h:5076
@ NK_LAYOUT_DYNAMIC_FREE
Definition: nuklear.h:5070
@ NK_LAYOUT_STATIC_FIXED
Definition: nuklear.h:5072
NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API void nk_contextual_close(struct nk_context *)
NK_API int nk_utf_len(const char *, int byte_len)
NK_API struct nk_color nk_hsv(int h, int s, int v)
NK_API void nk_plot_function(struct nk_context *, enum nk_chart_type, void *userdata, float(*value_getter)(void *user, int index), int count, int offset)
NK_API int nk_style_pop_style_item(struct nk_context *)
NK_API void nk_input_begin(struct nk_context *)
NK_API struct nk_style_item nk_style_item_image(struct nk_image img)
NK_API int nk_select_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags align, int value)
NK_API int nk_tooltip_begin(struct nk_context *, float width)
NK_API unsigned nk_check_flags_text(struct nk_context *, const char *, int, unsigned int flags, unsigned int value)
NK_API int nk_select_label(struct nk_context *, const char *, nk_flags align, int value)
NK_API struct nk_vec2 nk_rect_pos(struct nk_rect)
NK_API float nk_propertyf(struct nk_context *, const char *name, float min, float val, float max, float step, float inc_per_pixel)
NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context *, nk_flags, char *buffer, int max, nk_plugin_filter)
NK_API int nk_combo_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size)
nk_uint nk_hash
Definition: nuklear.h:191
#define NK_UINT8
Definition: nuklear.h:127
NK_API int nk_input_is_mouse_pressed(const struct nk_input *, enum nk_buttons)
NK_API int nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
NK_API void nk_layout_space_end(struct nk_context *)
NK_API int nk_input_is_mouse_released(const struct nk_input *, enum nk_buttons)
NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv)
NK_API int nk_checkbox_flags_label(struct nk_context *, const char *, unsigned int *flags, unsigned int value)
NK_API void nk_window_set_bounds(struct nk_context *, const char *name, struct nk_rect bounds)
NK_API int nk_style_set_cursor(struct nk_context *, enum nk_style_cursor)
NK_API struct nk_color nk_rgb_fv(const float *rgb)
NK_API void nk_popup_end(struct nk_context *)
NK_API int nk_select_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int value)
nk_chart_type
Definition: nuklear.h:258
@ NK_CHART_COLUMN
Definition: nuklear.h:258
@ NK_CHART_LINES
Definition: nuklear.h:258
@ NK_CHART_MAX
Definition: nuklear.h:258
nk_chart_event
Definition: nuklear.h:259
@ NK_CHART_HOVERING
Definition: nuklear.h:259
@ NK_CHART_CLICKED
Definition: nuklear.h:259
NK_API struct nk_color nk_rgb_hex(const char *rgb)
NK_API int nk_textedit_cut(struct nk_text_edit *)
NK_API void nk_edit_focus(struct nk_context *, nk_flags flags)
NK_API int nk_str_insert_at_char(struct nk_str *, int pos, const char *, int)
NK_API int nk_button_text(struct nk_context *, const char *title, int len)
NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context *, struct nk_vec2)
nk_symbol_type
Definition: nuklear.h:276
@ NK_SYMBOL_MAX
Definition: nuklear.h:290
@ NK_SYMBOL_X
Definition: nuklear.h:278
@ NK_SYMBOL_TRIANGLE_UP
Definition: nuklear.h:284
@ NK_SYMBOL_NONE
Definition: nuklear.h:277
@ NK_SYMBOL_TRIANGLE_LEFT
Definition: nuklear.h:286
@ NK_SYMBOL_CIRCLE_SOLID
Definition: nuklear.h:280
@ NK_SYMBOL_UNDERSCORE
Definition: nuklear.h:279
@ NK_SYMBOL_CIRCLE_OUTLINE
Definition: nuklear.h:281
@ NK_SYMBOL_TRIANGLE_DOWN
Definition: nuklear.h:285
@ NK_SYMBOL_RECT_OUTLINE
Definition: nuklear.h:283
@ NK_SYMBOL_MINUS
Definition: nuklear.h:289
@ NK_SYMBOL_RECT_SOLID
Definition: nuklear.h:282
@ NK_SYMBOL_TRIANGLE_RIGHT
Definition: nuklear.h:287
@ NK_SYMBOL_PLUS
Definition: nuklear.h:288
NK_API void nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
NK_API char * nk_str_get(struct nk_str *)
NK_API void nk_text_wrap_colored(struct nk_context *, const char *, int, struct nk_color)
NK_API void nk_str_remove_runes(struct nk_str *str, int len)
NK_API int nk_combo_item_label(struct nk_context *, const char *, nk_flags alignment)
NK_API int nk_str_append_str_utf8(struct nk_str *, const char *)
nk_window_flags
Definition: nuklear.h:5135
@ NK_WINDOW_PRIVATE
Definition: nuklear.h:5136
@ NK_WINDOW_CLOSED
Definition: nuklear.h:5145
@ NK_WINDOW_MINIMIZED
Definition: nuklear.h:5147
@ NK_WINDOW_HIDDEN
Definition: nuklear.h:5143
@ NK_WINDOW_ROM
Definition: nuklear.h:5139
@ NK_WINDOW_NOT_INTERACTIVE
Definition: nuklear.h:5141
@ NK_WINDOW_DYNAMIC
Definition: nuklear.h:5137
@ NK_WINDOW_REMOVE_ROM
Definition: nuklear.h:5149
NK_API struct nk_color nk_rgb_bv(const nk_byte *rgb)
NK_API struct nk_color nk_rgba_iv(const int *rgba)
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
NK_API int nk_window_is_closed(struct nk_context *, const char *)
NK_API void nk_chart_end(struct nk_context *)
NK_API float nk_window_get_height(const struct nk_context *)
#define NK_CLAMP(i, v, x)
Definition: nuklear.h:87
NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva)
#define NK_SCROLLBAR_HIDING_TIMEOUT
Definition: nuklear.h:26
NK_API int nk_button_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags text_alignment)
void(* nk_command_custom_callback)(void *canvas, short x, short y, unsigned short w, unsigned short h, nk_handle callback_data)
Definition: nuklear.h:4318
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
#define NK_LIB
Definition: nuklear.h:52
NK_API int nk_input_is_mouse_down(const struct nk_input *, enum nk_buttons)
NK_API struct nk_color nk_rgb_cf(struct nk_colorf c)
NK_API int nk_menu_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
#define NK_TEXTEDIT_UNDOCHARCOUNT
Definition: nuklear.h:4026
NK_API struct nk_color nk_rgb_f(float r, float g, float b)
nk_style_item_type
Definition: nuklear.h:4588
@ NK_STYLE_ITEM_IMAGE
Definition: nuklear.h:4590
@ NK_STYLE_ITEM_COLOR
Definition: nuklear.h:4589
NK_API void nk_window_get_scroll(struct nk_context *, nk_uint *offset_x, nk_uint *offset_y)
#define NK_FLAGS_STACK_SIZE
Definition: nuklear.h:5264
NK_API const char * nk_style_get_color_by_name(enum nk_style_colors)
NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed)
nk_buttons
Definition: nuklear.h:553
@ NK_BUTTON_LEFT
Definition: nuklear.h:554
@ NK_BUTTON_DOUBLE
Definition: nuklear.h:557
@ NK_BUTTON_MIDDLE
Definition: nuklear.h:555
@ NK_BUTTON_MAX
Definition: nuklear.h:558
@ NK_BUTTON_RIGHT
Definition: nuklear.h:556
NK_API int nk_chart_begin(struct nk_context *, enum nk_chart_type, int num, float min, float max)
NK_POINTER_TYPE nk_ptr
Definition: nuklear.h:189
NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API void nk_style_show_cursor(struct nk_context *)
NK_API void nk_fill_rect_multi_color(struct nk_command_buffer *, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom)
NK_API int nk_button_label_styled(struct nk_context *, const struct nk_style_button *, const char *title)
NK_API int nk_input_has_mouse_click(const struct nk_input *, enum nk_buttons)
NK_API int nk_option_text(struct nk_context *, const char *, int, int active)
#define NK_UTF_INVALID
Definition: nuklear.h:5397
nk_show_states
Definition: nuklear.h:257
@ NK_HIDDEN
Definition: nuklear.h:257
@ NK_SHOWN
Definition: nuklear.h:257
NK_API struct nk_vec2 nk_widget_position(struct nk_context *)
#define NK_LEN(a)
Definition: nuklear.h:5402
NK_API int nk_style_pop_flags(struct nk_context *)
NK_API int nk_utf_encode(nk_rune, char *, int)
nk_text_edit_type
Definition: nuklear.h:4052
@ NK_TEXT_EDIT_SINGLE_LINE
Definition: nuklear.h:4053
@ NK_TEXT_EDIT_MULTI_LINE
Definition: nuklear.h:4054
char nk_glyph[NK_UTF_SIZE]
Definition: nuklear.h:246
NK_API int nk_menu_begin_symbol(struct nk_context *, const char *, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_popup_close(struct nk_context *)
NK_API char * nk_str_at_rune(struct nk_str *, int pos, nk_rune *unicode, int *len)
NK_API nk_flags nk_chart_push(struct nk_context *, float)
NK_API void nk_window_set_scroll(struct nk_context *, nk_uint offset_x, nk_uint offset_y)
NK_API int nk_combo_item_text(struct nk_context *, const char *, int, nk_flags alignment)
NK_API struct nk_panel * nk_window_get_panel(struct nk_context *)
NK_API int nk_menu_begin_symbol_text(struct nk_context *, const char *, int, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
NK_API int nk_strfilter(const char *text, const char *regexp)
NK_API void nk_group_scrolled_end(struct nk_context *)
NK_API int nk_contextual_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
NK_INT16 nk_short
Definition: nuklear.h:184
NK_API void nk_buffer_push(struct nk_buffer *, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align)
NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
#define NK_TEXTEDIT_UNDOSTATECOUNT
Definition: nuklear.h:4022
NK_API void nk_textedit_delete(struct nk_text_edit *, int where, int len)
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
NK_API void nk_label_colored_wrap(struct nk_context *, const char *, struct nk_color)
#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)
Definition: nuklear.h:5271
NK_API const struct nk_command * nk__begin(struct nk_context *)
NK_API int nk_utf_decode(const char *, nk_rune *, int)
NK_API int nk_tree_element_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, int *selected, const char *hash, int len, int seed)
NK_API void nk_button_set_behavior(struct nk_context *, enum nk_button_behavior)
#define NK_INT16
Definition: nuklear.h:130
NK_API struct nk_color nk_hsv_fv(const float *hsv)
NK_API void nk_group_get_scroll(struct nk_context *, const char *id, nk_uint *x_offset, nk_uint *y_offset)
NK_API int nk_button_image(struct nk_context *, struct nk_image img)
#define NK_ABS(a)
Definition: nuklear.h:5403
NK_API void nk_str_init(struct nk_str *, const struct nk_allocator *, nk_size size)
#define NK_STATIC_ASSERT(exp)
Definition: nuklear.h:74
NK_API int nk_style_push_color(struct nk_context *, struct nk_color *, struct nk_color)
NK_API struct nk_colorf nk_hsva_colorfv(float *c)
NK_API int nk_combo_begin_label(struct nk_context *, const char *selected, struct nk_vec2 size)
NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in)
NK_API int nk_str_append_text_utf8(struct nk_str *, const char *, int)
NK_API int nk_button_symbol(struct nk_context *, enum nk_symbol_type)
NK_API int nk_combo_begin_color(struct nk_context *, struct nk_color color, struct nk_vec2 size)
NK_API int nk_str_append_str_runes(struct nk_str *, const nk_rune *)
#define NK_POINTER_TYPE
Definition: nuklear.h:176
NK_API int nk_menu_begin_label(struct nk_context *, const char *, nk_flags align, struct nk_vec2 size)
NK_API int nk_input_mouse_clicked(const struct nk_input *, enum nk_buttons, struct nk_rect)
NK_API void nk_stroke_circle(struct nk_command_buffer *, struct nk_rect, float line_thickness, struct nk_color)
NK_API int nk_selectable_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int *value)
#define NK_UTF_SIZE
Definition: nuklear.h:18
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
NK_API int nk_contextual_begin(struct nk_context *, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds)
NK_API void nk_str_init_fixed(struct nk_str *, void *memory, nk_size size)
#define NK_ALIGN_PTR(x, mask)
Definition: nuklear.h:5439
NK_API void nk_text(struct nk_context *, const char *, int, nk_flags)
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect *, struct nk_context *, struct nk_vec2)
NK_API int nk_menu_item_label(struct nk_context *, const char *, nk_flags alignment)
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context *, struct nk_rect)
NK_API int nk_filter_ascii(const struct nk_text_edit *, nk_rune unicode)
void(* nk_plugin_paste)(nk_handle, struct nk_text_edit *)
Definition: nuklear.h:268
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, int down)
NK_API int nk_style_pop_font(struct nk_context *)
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color)
nk_modify
Definition: nuklear.h:254
@ NK_FIXED
Definition: nuklear.h:254
@ NK_MODIFIABLE
Definition: nuklear.h:254
NK_API void nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
NK_API int nk_widget_is_hovered(struct nk_context *)
NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context *)
NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color)
NK_API void nk_edit_unfocus(struct nk_context *)
NK_API int nk_button_pop_behavior(struct nk_context *)
NK_API int nk_menu_begin_image_text(struct nk_context *, const char *, int, nk_flags align, struct nk_image, struct nk_vec2 size)
nk_tree_type
Definition: nuklear.h:263
@ NK_TREE_NODE
Definition: nuklear.h:263
@ NK_TREE_TAB
Definition: nuklear.h:263
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color)
NK_API int nk_option_label(struct nk_context *, const char *, int active)
NK_API float nk_slide_float(struct nk_context *, float min, float val, float max, float step)
NK_API int nk_strtoi(const char *str, const char **endptr)
NK_API int nk_combo_string(struct nk_context *, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_stricmp(const char *s1, const char *s2)
NK_API int nk_tree_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
NK_API void nk_tree_element_pop(struct nk_context *)
NK_API int nk_window_is_any_hovered(struct nk_context *)
NK_API int nk_str_append_str_char(struct nk_str *, const char *)
NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
NK_API void nk_style_load_cursor(struct nk_context *, enum nk_style_cursor, const struct nk_cursor *)
NK_API int nk_str_len(struct nk_str *)
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color)
NK_API void nk_color_hex_rgb(char *output, struct nk_color)
NK_API int nk_list_view_begin(struct nk_context *, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count)
NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color)
#define NK_BUTTON_BEHAVIOR_STACK_SIZE
Definition: nuklear.h:5244
NK_API void nk_window_collapse_if(struct nk_context *, const char *name, enum nk_collapse_states, int cond)
NK_API int nk_contextual_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
NK_API void nk_window_show_if(struct nk_context *, const char *name, enum nk_show_states, int cond)
NK_API void nk_list_view_end(struct nk_list_view *)
NK_API struct nk_rect nk_rectiv(const int *xywh)
NK_API int nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align)
NK_API struct nk_vec2 nk_vec2v(const float *xy)
NK_API void nk_str_delete_chars(struct nk_str *, int pos, int len)
NK_API int nk_combo_begin_symbol(struct nk_context *, enum nk_symbol_type, struct nk_vec2 size)
NK_API struct nk_color nk_hsva_fv(const float *hsva)
#define NK_INPUT_MAX
Definition: nuklear.h:20
NK_API int nk_contextual_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
nk_command_clipping
Definition: nuklear.h:4340
@ NK_CLIPPING_OFF
Definition: nuklear.h:4341
@ NK_CLIPPING_ON
Definition: nuklear.h:4342
NK_API void nk_menubar_end(struct nk_context *)
NK_API int nk_str_insert_str_runes(struct nk_str *, int pos, const nk_rune *)
NK_API void nk_spacing(struct nk_context *, int cols)
nk_text_alignment
Definition: nuklear.h:2863
@ NK_TEXT_CENTERED
Definition: nuklear.h:2865
@ NK_TEXT_RIGHT
Definition: nuklear.h:2866
@ NK_TEXT_LEFT
Definition: nuklear.h:2864
NK_API int nk_style_pop_float(struct nk_context *)
NK_API void nk_style_default(struct nk_context *)
NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
NK_API struct nk_rect nk_recti(int x, int y, int w, int h)
NK_API void nk_stroke_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color)
nk_uint nk_rune
Definition: nuklear.h:193
#define nk_zero_struct(s)
Definition: nuklear.h:5419
NK_API int nk_filter_oct(const struct nk_text_edit *, nk_rune unicode)
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context *, struct nk_rect)
NK_API struct nk_image nk_image_ptr(void *)
NK_API const char * nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len)
NK_API int nk_strlen(const char *str)
NK_API void nk_buffer_free(struct nk_buffer *)
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
NK_API int nk_check_text(struct nk_context *, const char *, int, int active)
NK_API void nk_style_load_all_cursors(struct nk_context *, struct nk_cursor *)
NK_API struct nk_rect nk_layout_widget_bounds(struct nk_context *)
#define NK_INTERN
Definition: nuklear.h:56
NK_API void nk_stroke_triangle(struct nk_command_buffer *, float, float, float, float, float, float, float line_thichness, struct nk_color)
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
NK_API int nk_style_push_style_item(struct nk_context *, struct nk_style_item *, struct nk_style_item)
NK_API void nk_tooltip(struct nk_context *, const char *)
NK_API int nk_style_push_font(struct nk_context *, const struct nk_user_font *)
NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value)
NK_API nk_handle nk_handle_id(int)
#define NK_SATURATE(x)
Definition: nuklear.h:5401
int(* nk_plugin_filter)(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:267
NK_API int nk_button_image_label_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_str_insert_at_rune(struct nk_str *, int pos, const char *, int)
NK_API void nk_combo_end(struct nk_context *)
NK_API int nk_str_insert_text_utf8(struct nk_str *, int pos, const char *, int)
nk_color_format
Definition: nuklear.h:260
@ NK_RGB
Definition: nuklear.h:260
@ NK_RGBA
Definition: nuklear.h:260
NK_API int nk_widget_is_mouse_clicked(struct nk_context *, enum nk_buttons)
NK_API void nk_buffer_init(struct nk_buffer *, const struct nk_allocator *, nk_size size)
nk_style_colors
Definition: nuklear.h:3344
@ NK_COLOR_HEADER
Definition: nuklear.h:3347
@ NK_COLOR_CHART
Definition: nuklear.h:3365
@ NK_COLOR_SCROLLBAR_CURSOR_ACTIVE
Definition: nuklear.h:3371
@ NK_COLOR_SLIDER_CURSOR_ACTIVE
Definition: nuklear.h:3360
@ NK_COLOR_EDIT_CURSOR
Definition: nuklear.h:3363
@ NK_COLOR_SELECT_ACTIVE
Definition: nuklear.h:3356
@ NK_COLOR_TEXT
Definition: nuklear.h:3345
@ NK_COLOR_BUTTON_ACTIVE
Definition: nuklear.h:3351
@ NK_COLOR_SELECT
Definition: nuklear.h:3355
@ NK_COLOR_TOGGLE_CURSOR
Definition: nuklear.h:3354
@ NK_COLOR_SCROLLBAR_CURSOR
Definition: nuklear.h:3369
@ NK_COLOR_BUTTON
Definition: nuklear.h:3349
@ NK_COLOR_SLIDER_CURSOR_HOVER
Definition: nuklear.h:3359
@ NK_COLOR_CHART_COLOR_HIGHLIGHT
Definition: nuklear.h:3367
@ NK_COLOR_CHART_COLOR
Definition: nuklear.h:3366
@ NK_COLOR_SCROLLBAR
Definition: nuklear.h:3368
@ NK_COLOR_SLIDER
Definition: nuklear.h:3357
@ NK_COLOR_EDIT
Definition: nuklear.h:3362
@ NK_COLOR_COUNT
Definition: nuklear.h:3373
@ NK_COLOR_BUTTON_HOVER
Definition: nuklear.h:3350
@ NK_COLOR_TOGGLE_HOVER
Definition: nuklear.h:3353
@ NK_COLOR_SCROLLBAR_CURSOR_HOVER
Definition: nuklear.h:3370
@ NK_COLOR_WINDOW
Definition: nuklear.h:3346
@ NK_COLOR_COMBO
Definition: nuklear.h:3364
@ NK_COLOR_BORDER
Definition: nuklear.h:3348
@ NK_COLOR_TOGGLE
Definition: nuklear.h:3352
@ NK_COLOR_TAB_HEADER
Definition: nuklear.h:3372
@ NK_COLOR_SLIDER_CURSOR
Definition: nuklear.h:3358
@ NK_COLOR_PROPERTY
Definition: nuklear.h:3361
NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_buffer_reset(struct nk_buffer *, enum nk_buffer_allocation_type type)
NK_API void nk_popup_get_scroll(struct nk_context *, nk_uint *offset_x, nk_uint *offset_y)
#define NK_UINT32
Definition: nuklear.h:146
#define NK_PTR_TO_UINT(x)
Definition: nuklear.h:5430
#define NK_CONFIG_STACK(type, size)
Definition: nuklear.h:5276
NK_API void * nk_buffer_memory(struct nk_buffer *)
NK_API void nk_buffer_init_fixed(struct nk_buffer *, void *memory, nk_size size)
#define NK_FONT_STACK_SIZE
Definition: nuklear.h:5248
NK_API int nk_str_len_char(struct nk_str *)
NK_API void nk_combobox_string(struct nk_context *, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input *, struct nk_rect)
NK_API int nk_filter_decimal(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_textedit_paste(struct nk_text_edit *, char const *, int len)
NK_SIZE_TYPE nk_size
Definition: nuklear.h:188
#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
Definition: nuklear.h:5029
NK_API const void * nk_buffer_memory_const(const struct nk_buffer *)
NK_API void nk_layout_row_template_end(struct nk_context *)
NK_API nk_size nk_prog(struct nk_context *, nk_size cur, nk_size max, int modifyable)
NK_API int nk_button_image_text_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API int nk_combo_item_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags alignment)
NK_API int nk_progress(struct nk_context *, nk_size *cur, nk_size max, int modifyable)
NK_API void nk_menubar_begin(struct nk_context *)
NK_API int nk_str_insert_str_char(struct nk_str *, int pos, const char *)
NK_API struct nk_image nk_image_id(int)
NK_API int nk_filter_float(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_style_pop_color(struct nk_context *)
NK_API void nk_layout_reset_min_row_height(struct nk_context *)
nk_widget_states
Definition: nuklear.h:2829
@ NK_WIDGET_STATE_MODIFIED
Definition: nuklear.h:2830
@ NK_WIDGET_STATE_LEFT
Definition: nuklear.h:2835
@ NK_WIDGET_STATE_ACTIVED
Definition: nuklear.h:2834
@ NK_WIDGET_STATE_ENTERED
Definition: nuklear.h:2832
@ NK_WIDGET_STATE_HOVER
Definition: nuklear.h:2833
@ NK_WIDGET_STATE_ACTIVE
Definition: nuklear.h:2837
@ NK_WIDGET_STATE_HOVERED
Definition: nuklear.h:2836
@ NK_WIDGET_STATE_INACTIVE
Definition: nuklear.h:2831
nk_collapse_states
Definition: nuklear.h:256
@ NK_MINIMIZED
Definition: nuklear.h:256
@ NK_MAXIMIZED
Definition: nuklear.h:256
#define NK_STYLE_ITEM_STACK_SIZE
Definition: nuklear.h:5252
NK_API int nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba)
#define NK_VALUE_PAGE_CAPACITY
Definition: nuklear.h:5312
NK_API void nk_textedit_redo(struct nk_text_edit *)
#define NK_INT32
Definition: nuklear.h:139
#define nk_vec2_muls(a, t)
Definition: nuklear.h:5415
NK_API const char * nk_str_get_const(const struct nk_str *)
NK_API float nk_strtof(const char *str, const char **endptr)
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score)
NK_API void nk_window_collapse(struct nk_context *, const char *name, enum nk_collapse_states state)
NK_API int nk_widget_has_mouse_click_down(struct nk_context *, enum nk_buttons, int down)
NK_API struct nk_vec2 nk_vec2(float x, float y)
#define NK_INBOX(px, py, x, y, w, h)
Definition: nuklear.h:5405
#define NK_ALIGN_PTR_BACK(x, mask)
Definition: nuklear.h:5441
NK_API int nk_radio_label(struct nk_context *, const char *, int *active)
NK_API void nk_textedit_select_all(struct nk_text_edit *)
NK_API void nk_image_color(struct nk_context *, struct nk_image, struct nk_color)
NK_UINT32 nk_uint
Definition: nuklear.h:187
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color)
#define NK_COLOR_STACK_SIZE
Definition: nuklear.h:5268
NK_API int nk_str_insert_text_runes(struct nk_str *, int pos, const nk_rune *, int)
NK_API struct nk_colorf nk_color_cf(struct nk_color)
NK_API void nk_text_wrap(struct nk_context *, const char *, int)
float(* nk_text_width_f)(nk_handle, float h, const char *, int len)
Definition: nuklear.h:3679
NK_API int nk_selectable_label(struct nk_context *, const char *, nk_flags align, int *value)
NK_API int nk_str_insert_str_utf8(struct nk_str *, int pos, const char *)
NK_API int nk_window_has_focus(const struct nk_context *)
NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context *, struct nk_vec2)
NK_API nk_flags nk_chart_push_slot(struct nk_context *, float, int)
NK_API int nk_checkbox_flags_text(struct nk_context *, const char *, int, unsigned int *flags, unsigned int value)
NK_API void nk_push_custom(struct nk_command_buffer *, struct nk_rect, nk_command_custom_callback, nk_handle usr)
nk_text_align
Definition: nuklear.h:2855
@ NK_TEXT_ALIGN_BOTTOM
Definition: nuklear.h:2861
@ NK_TEXT_ALIGN_MIDDLE
Definition: nuklear.h:2860
@ NK_TEXT_ALIGN_CENTERED
Definition: nuklear.h:2857
@ NK_TEXT_ALIGN_RIGHT
Definition: nuklear.h:2858
@ NK_TEXT_ALIGN_TOP
Definition: nuklear.h:2859
@ NK_TEXT_ALIGN_LEFT
Definition: nuklear.h:2856
NK_API int nk_checkbox_text(struct nk_context *, const char *, int, int *active)
NK_API struct nk_color nk_hsv_f(float h, float s, float v)
nk_anti_aliasing
Definition: nuklear.h:925
@ NK_ANTI_ALIASING_ON
Definition: nuklear.h:925
@ NK_ANTI_ALIASING_OFF
Definition: nuklear.h:925
NK_API int nk_style_push_flags(struct nk_context *, nk_flags *, nk_flags)
NK_API struct nk_rect nk_widget_bounds(struct nk_context *)
NK_API void nk_combobox_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_str_append_text_runes(struct nk_str *, const nk_rune *, int)
NK_API int nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
NK_API void nk_combo_close(struct nk_context *)
#define nk_vec2_sub(a, b)
Definition: nuklear.h:5412
NK_API float nk_layout_ratio_from_pixel(struct nk_context *, float pixel_width)
NK_API unsigned nk_check_flags_label(struct nk_context *, const char *, unsigned int flags, unsigned int value)
NK_API int nk_tree_state_image_push(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state)
NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a)
#define nk_ptr_add_const(t, p, i)
Definition: nuklear.h:5418
NK_API void nk_tooltip_end(struct nk_context *)
NK_API void nk_layout_set_min_row_height(struct nk_context *, float height)
NK_API void nk_push_scissor(struct nk_command_buffer *, struct nk_rect)
NK_API void nk_stroke_curve(struct nk_command_buffer *, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color)
NK_API int nk_menu_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
#define NK_GLOBAL
Definition: nuklear.h:58
nk_text_edit_mode
Definition: nuklear.h:4057
@ NK_TEXT_EDIT_MODE_VIEW
Definition: nuklear.h:4058
@ NK_TEXT_EDIT_MODE_REPLACE
Definition: nuklear.h:4060
@ NK_TEXT_EDIT_MODE_INSERT
Definition: nuklear.h:4059
NK_API int nk_selectable_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int *value)
NK_API void nk_textedit_text(struct nk_text_edit *, const char *, int total_len)
NK_API void nk_fill_polygon(struct nk_command_buffer *, float *, int point_count, struct nk_color)
NK_API int nk_style_push_vec2(struct nk_context *, struct nk_vec2 *, struct nk_vec2)
nk_edit_types
Definition: nuklear.h:3213
@ NK_EDIT_SIMPLE
Definition: nuklear.h:3214
@ NK_EDIT_FIELD
Definition: nuklear.h:3215
@ NK_EDIT_EDITOR
Definition: nuklear.h:3217
@ NK_EDIT_BOX
Definition: nuklear.h:3216
void(* nk_plugin_free)(nk_handle, void *old)
Definition: nuklear.h:266
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
NK_API nk_flags nk_edit_string(struct nk_context *, nk_flags, char *buffer, int *len, int max, nk_plugin_filter)
NK_API void nk_stroke_polyline(struct nk_command_buffer *, float *points, int point_count, float line_thickness, struct nk_color col)
NK_API int nk_button_symbol_text_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API void nk_style_hide_cursor(struct nk_context *)
nk_allocation_type
Definition: nuklear.h:3884
@ NK_BUFFER_FIXED
Definition: nuklear.h:3885
@ NK_BUFFER_DYNAMIC
Definition: nuklear.h:3886
NK_API int nk_menu_item_text(struct nk_context *, const char *, int, nk_flags align)
nk_button_behavior
Definition: nuklear.h:253
@ NK_BUTTON_DEFAULT
Definition: nuklear.h:253
@ NK_BUTTON_REPEATER
Definition: nuklear.h:253
NK_API struct nk_colorf nk_color_picker(struct nk_context *, struct nk_colorf, enum nk_color_format)
NK_API void nk_window_set_size(struct nk_context *, const char *name, struct nk_vec2)
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *)
#define nk_foreach(c, ctx)
Definition: nuklear.h:993
NK_API int nk_menu_begin_image_label(struct nk_context *, const char *, nk_flags align, struct nk_image, struct nk_vec2 size)
NK_API struct nk_color nk_hsva(int h, int s, int v, int a)
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect *, const struct nk_context *)
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect bounds)
NK_API struct nk_vec2 nk_widget_size(struct nk_context *)
NK_API struct nk_color nk_rgba_u32(nk_uint)
NK_API void nk_group_set_scroll(struct nk_context *, const char *id, nk_uint x_offset, nk_uint y_offset)
#define NK_SIZE_TYPE
Definition: nuklear.h:161
NK_API double nk_strtod(const char *str, const char **endptr)
NK_API void nk_fill_triangle(struct nk_command_buffer *, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color)
NK_API struct nk_vec2 nk_rect_size(struct nk_rect)
NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input *, struct nk_rect)
NK_API void nk_layout_row_template_begin(struct nk_context *, float row_height)
NK_API int nk_select_text(struct nk_context *, const char *, int, nk_flags align, int value)
NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color)
NK_API int nk_input_is_key_released(const struct nk_input *, enum nk_keys)
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API void nk_color_fv(float *rgba_out, struct nk_color)
NK_API void nk_layout_row_push(struct nk_context *, float value)
NK_API void nk_input_char(struct nk_context *, char)
NK_API void nk_str_clear(struct nk_str *)
NK_API int nk_combo_begin_symbol_text(struct nk_context *, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size)
void(* nk_query_font_glyph_f)(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
Definition: nuklear.h:3680
NK_API int nk_image_is_subimage(const struct nk_image *img)
NK_API void nk_plot(struct nk_context *, enum nk_chart_type, const float *values, int count, int offset)
NK_API struct nk_rect nk_rectv(const float *xywh)
NK_API int nk_init(struct nk_context *, struct nk_allocator *, const struct nk_user_font *)
NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input *, struct nk_rect)
NK_API int nk_combo_begin_image_text(struct nk_context *, const char *selected, int, struct nk_image, struct nk_vec2 size)
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
#define NK_MIN(a, b)
Definition: nuklear.h:85
NK_API struct nk_vec2 nk_vec2i(int x, int y)
#define NK_UINT16
Definition: nuklear.h:133
NK_API void nk_text_colored(struct nk_context *, const char *, int, nk_flags, struct nk_color)
nk_widget_layout_states
Definition: nuklear.h:2824
@ NK_WIDGET_ROM
Definition: nuklear.h:2827
@ NK_WIDGET_VALID
Definition: nuklear.h:2826
@ NK_WIDGET_INVALID
Definition: nuklear.h:2825
NK_API void nk_textedit_delete_selection(struct nk_text_edit *)
#define NK_BETWEEN(x, a, b)
Definition: nuklear.h:5404
nk_command_type
Definition: nuklear.h:4157
@ NK_COMMAND_RECT_FILLED
Definition: nuklear.h:4163
@ NK_COMMAND_POLYLINE
Definition: nuklear.h:4173
@ NK_COMMAND_SCISSOR
Definition: nuklear.h:4159
@ NK_COMMAND_POLYGON_FILLED
Definition: nuklear.h:4172
@ NK_COMMAND_ARC
Definition: nuklear.h:4167
@ NK_COMMAND_TRIANGLE_FILLED
Definition: nuklear.h:4170
@ NK_COMMAND_RECT
Definition: nuklear.h:4162
@ NK_COMMAND_POLYGON
Definition: nuklear.h:4171
@ NK_COMMAND_NOP
Definition: nuklear.h:4158
@ NK_COMMAND_CUSTOM
Definition: nuklear.h:4176
@ NK_COMMAND_CURVE
Definition: nuklear.h:4161
@ NK_COMMAND_CIRCLE
Definition: nuklear.h:4165
@ NK_COMMAND_IMAGE
Definition: nuklear.h:4175
@ NK_COMMAND_TRIANGLE
Definition: nuklear.h:4169
@ NK_COMMAND_TEXT
Definition: nuklear.h:4174
@ NK_COMMAND_LINE
Definition: nuklear.h:4160
@ NK_COMMAND_CIRCLE_FILLED
Definition: nuklear.h:4166
@ NK_COMMAND_RECT_MULTI_COLOR
Definition: nuklear.h:4164
@ NK_COMMAND_ARC_FILLED
Definition: nuklear.h:4168
NK_API void nk_combobox(struct nk_context *, const char **items, int count, int *selected, int item_height, struct nk_vec2 size)
NK_API int nk_button_color(struct nk_context *, struct nk_color)
NK_API int nk_button_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API struct nk_color nk_rgb_iv(const int *rgb)
NK_API int nk_str_append_text_char(struct nk_str *, const char *, int)
nk_popup_type
Definition: nuklear.h:261
@ NK_POPUP_DYNAMIC
Definition: nuklear.h:261
@ NK_POPUP_STATIC
Definition: nuklear.h:261
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
NK_API int nk_menu_begin_symbol_label(struct nk_context *, const char *, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
#define nk_vec2_len_sqr(a)
Definition: nuklear.h:5414
NK_API int nk_menu_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API void nk_textedit_init_fixed(struct nk_text_edit *, void *memory, nk_size size)
NK_API int nk_button_symbol_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type)
nk_style_cursor
Definition: nuklear.h:3375
@ NK_CURSOR_TEXT
Definition: nuklear.h:3377
@ NK_CURSOR_MOVE
Definition: nuklear.h:3378
@ NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT
Definition: nuklear.h:3382
@ NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT
Definition: nuklear.h:3381
@ NK_CURSOR_RESIZE_HORIZONTAL
Definition: nuklear.h:3380
@ NK_CURSOR_COUNT
Definition: nuklear.h:3383
@ NK_CURSOR_ARROW
Definition: nuklear.h:3376
@ NK_CURSOR_RESIZE_VERTICAL
Definition: nuklear.h:3379
NK_API int nk_button_image_text(struct nk_context *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in)
NK_API void nk_style_from_table(struct nk_context *, const struct nk_color *)
NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color)
NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down)
NK_API int nk_color_pick(struct nk_context *, struct nk_colorf *, enum nk_color_format)
NK_API int nk_style_push_float(struct nk_context *, float *, float)
NK_API int nk_chart_begin_colored(struct nk_context *, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max)
NK_API int nk_select_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags align, int value)
#define NK_CHART_MAX_SLOT
Definition: nuklear.h:5032
NK_API int nk_window_is_active(struct nk_context *, const char *)
NK_API int nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *off, const char *title, nk_flags)
NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value)
#define nk_ptr_add(t, p, i)
Definition: nuklear.h:5417
NK_API void nk_input_motion(struct nk_context *, int x, int y)
NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color)
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
#define NK_INT8
Definition: nuklear.h:124
NK_API int nk_combo_begin_symbol_label(struct nk_context *, const char *selected, enum nk_symbol_type, struct nk_vec2 size)
NK_API int nk_menu_begin_image(struct nk_context *, const char *, struct nk_image, struct nk_vec2 size)
#define NK_MAX(a, b)
Definition: nuklear.h:86
NK_API void nk_window_set_position(struct nk_context *, const char *name, struct nk_vec2 pos)
NK_API void nk_color_hex_rgba(char *output, struct nk_color)
NK_API int nk_str_insert_text_char(struct nk_str *, int pos, const char *, int)
NK_API int nk_button_image_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img)
NK_API void nk_window_set_focus(struct nk_context *, const char *name)
NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color)
NK_API int nk_selectable_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags align, int *value)
NK_API const char * nk_str_at_char_const(const struct nk_str *, int pos)
NK_API int nk_selectable_text(struct nk_context *, const char *, int, nk_flags align, int *value)
NK_API struct nk_color nk_rgba_cf(struct nk_colorf c)
NK_API int nk_combo_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
NK_UINT16 nk_ushort
Definition: nuklear.h:185
nk_panel_flags
Definition: nuklear.h:1233
@ NK_WINDOW_TITLE
Definition: nuklear.h:1240
@ NK_WINDOW_SCALABLE
Definition: nuklear.h:1236
@ NK_WINDOW_SCALE_LEFT
Definition: nuklear.h:1243
@ NK_WINDOW_MOVABLE
Definition: nuklear.h:1235
@ NK_WINDOW_MINIMIZABLE
Definition: nuklear.h:1238
@ NK_WINDOW_CLOSABLE
Definition: nuklear.h:1237
@ NK_WINDOW_BORDER
Definition: nuklear.h:1234
@ NK_WINDOW_BACKGROUND
Definition: nuklear.h:1242
@ NK_WINDOW_NO_INPUT
Definition: nuklear.h:1244
@ NK_WINDOW_NO_SCROLLBAR
Definition: nuklear.h:1239
@ NK_WINDOW_SCROLL_AUTO_HIDE
Definition: nuklear.h:1241
NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context *)
NK_API struct nk_style_item nk_style_item_color(struct nk_color)
#define NK_MAX_NUMBER_BUFFER
Definition: nuklear.h:23
NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color)
#define NK_UNUSED(x)
Definition: nuklear.h:5400
NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect, int down)
NK_API struct nk_image nk_subimage_ptr(void *, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score)
NK_API int nk_group_begin(struct nk_context *, const char *title, nk_flags)
NK_API void nk_textedit_free(struct nk_text_edit *)
nk_buffer_allocation_type
Definition: nuklear.h:3889
@ NK_BUFFER_BACK
Definition: nuklear.h:3891
@ NK_BUFFER_MAX
Definition: nuklear.h:3892
@ NK_BUFFER_FRONT
Definition: nuklear.h:3890
NK_API int nk_window_is_hovered(struct nk_context *)
NK_API int nk_combo_begin_text(struct nk_context *, const char *selected, int, struct nk_vec2 size)
NK_API void nk_buffer_info(struct nk_memory_status *, struct nk_buffer *)
NK_API void nk_clear(struct nk_context *)
NK_API int nk_style_pop_vec2(struct nk_context *)
nk_style_header_align
Definition: nuklear.h:4929
@ NK_HEADER_RIGHT
Definition: nuklear.h:4931
@ NK_HEADER_LEFT
Definition: nuklear.h:4930
NK_API int nk_contextual_item_label(struct nk_context *, const char *, nk_flags align)
NK_API void nk_label_colored(struct nk_context *, const char *, nk_flags align, struct nk_color)
NK_API void nk_end(struct nk_context *ctx)
NK_API int nk_window_is_hidden(struct nk_context *, const char *)
NK_API void nk_fill_circle(struct nk_command_buffer *, struct nk_rect, struct nk_color)
NK_API void nk_group_end(struct nk_context *)
NK_API void nk_str_remove_chars(struct nk_str *, int len)
NK_API int nk_menu_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API void nk_window_show(struct nk_context *, const char *name, enum nk_show_states)
#define NK_PI
Definition: nuklear.h:5396
NK_API int nk_combo_begin_image(struct nk_context *, struct nk_image img, struct nk_vec2 size)
NK_API float nk_widget_height(struct nk_context *)
#define NK_FLOAT_STACK_SIZE
Definition: nuklear.h:5256
#define NK_MAX_FLOAT_PRECISION
Definition: nuklear.h:5398
NK_API int nk_combo_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *userdata, int selected, int count, int item_height, struct nk_vec2 size)
nk_panel_type
Definition: nuklear.h:5035
@ NK_PANEL_NONE
Definition: nuklear.h:5036
@ NK_PANEL_WINDOW
Definition: nuklear.h:5037
@ NK_PANEL_POPUP
Definition: nuklear.h:5039
@ NK_PANEL_CONTEXTUAL
Definition: nuklear.h:5040
@ NK_PANEL_GROUP
Definition: nuklear.h:5038
@ NK_PANEL_TOOLTIP
Definition: nuklear.h:5043
@ NK_PANEL_COMBO
Definition: nuklear.h:5041
@ NK_PANEL_MENU
Definition: nuklear.h:5042
NK_API void nk_stroke_polygon(struct nk_command_buffer *, float *, int point_count, float line_thickness, struct nk_color)
NK_API void nk_buffer_clear(struct nk_buffer *)
nk_layout_format
Definition: nuklear.h:262
@ NK_DYNAMIC
Definition: nuklear.h:262
@ NK_STATIC
Definition: nuklear.h:262
NK_API void nk_textedit_undo(struct nk_text_edit *)
NK_API int nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
NK_INT32 nk_int
Definition: nuklear.h:186
NK_API int nk_select_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int value)
NK_API nk_flags nk_edit_buffer(struct nk_context *, nk_flags, struct nk_text_edit *, nk_plugin_filter)
NK_API void nk_label_wrap(struct nk_context *, const char *)
NK_API int nk_slider_float(struct nk_context *, float min, float *val, float max, float step)
NK_API void nk_draw_text(struct nk_command_buffer *, struct nk_rect, const char *text, int len, const struct nk_user_font *, struct nk_color, struct nk_color)
NK_API int nk_contextual_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
#define NK_WINDOW_MAX_NAME
Definition: nuklear.h:5131
NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading)
NK_API int nk_button_label(struct nk_context *, const char *title)
nk_panel_set
Definition: nuklear.h:5045
@ NK_PANEL_SET_POPUP
Definition: nuklear.h:5047
@ NK_PANEL_SET_NONBLOCK
Definition: nuklear.h:5046
@ NK_PANEL_SET_SUB
Definition: nuklear.h:5048
NK_API int nk_popup_begin(struct nk_context *, enum nk_popup_type, const char *, nk_flags, struct nk_rect bounds)
NK_API int nk_filter_binary(const struct nk_text_edit *, nk_rune unicode)
NK_API nk_rune nk_str_rune_at(const struct nk_str *, int pos)
NK_API int nk_filter_hex(const struct nk_text_edit *, nk_rune unicode)
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
NK_API struct nk_color nk_rgba(int r, int g, int b, int a)
NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color)
NK_API struct nk_style_item nk_style_item_hide(void)
nk_orientation
Definition: nuklear.h:255
@ NK_VERTICAL
Definition: nuklear.h:255
@ NK_HORIZONTAL
Definition: nuklear.h:255
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
NK_API int nk_menu_begin_text(struct nk_context *, const char *title, int title_len, nk_flags align, struct nk_vec2 size)
NK_API int nk_radio_text(struct nk_context *, const char *, int, int *active)
nk_edit_events
Definition: nuklear.h:3219
@ NK_EDIT_INACTIVE
Definition: nuklear.h:3221
@ NK_EDIT_DEACTIVATED
Definition: nuklear.h:3223
@ NK_EDIT_ACTIVE
Definition: nuklear.h:3220
@ NK_EDIT_COMMITED
Definition: nuklear.h:3224
@ NK_EDIT_ACTIVATED
Definition: nuklear.h:3222
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
NK_API int nk_combo(struct nk_context *, const char **items, int count, int selected, int item_height, struct nk_vec2 size)
NK_API void nk_fill_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, struct nk_color)
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
NK_API void nk_contextual_end(struct nk_context *)
NK_UINT8 nk_uchar
Definition: nuklear.h:182
NK_API void nk_textedit_init(struct nk_text_edit *, struct nk_allocator *, nk_size size)
NK_API int nk_stricmpn(const char *s1, const char *s2, int n)
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
NK_API struct nk_color nk_rgba_fv(const float *rgba)
#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1)
Definition: nuklear.h:5407
NK_API int nk_group_begin_titled(struct nk_context *, const char *name, const char *title, nk_flags)
NK_API int nk_combo_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API int nk_button_push_behavior(struct nk_context *, enum nk_button_behavior)
NK_API void nk_style_set_font(struct nk_context *, const struct nk_user_font *)
nk_heading
Definition: nuklear.h:252
@ NK_RIGHT
Definition: nuklear.h:252
@ NK_DOWN
Definition: nuklear.h:252
@ NK_UP
Definition: nuklear.h:252
@ NK_LEFT
Definition: nuklear.h:252
void *(* nk_plugin_alloc)(nk_handle, void *old, nk_size)
Definition: nuklear.h:265
NK_API int nk_input_is_key_down(const struct nk_input *, enum nk_keys)
NK_API int nk_tree_element_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, int *selected, const char *hash, int len, int seed)
NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a)
Definition: nuklear.h:271
nk_handle userdata
Definition: nuklear.h:272
nk_plugin_alloc alloc
Definition: nuklear.h:273
nk_plugin_free free
Definition: nuklear.h:274
Definition: nuklear.h:3895
int active
Definition: nuklear.h:3896
nk_size offset
Definition: nuklear.h:3897
Definition: nuklear.h:3901
struct nk_allocator pool
Definition: nuklear.h:3904
struct nk_memory memory
Definition: nuklear.h:3908
enum nk_allocation_type type
Definition: nuklear.h:3906
nk_size needed
Definition: nuklear.h:3914
nk_size size
Definition: nuklear.h:3918
nk_size allocated
Definition: nuklear.h:3912
struct nk_buffer_marker marker[NK_BUFFER_MAX]
Definition: nuklear.h:3902
float grow_factor
Definition: nuklear.h:3910
nk_size calls
Definition: nuklear.h:3916
Definition: nuklear.h:5051
struct nk_color highlight
Definition: nuklear.h:5054
int count
Definition: nuklear.h:5056
struct nk_color color
Definition: nuklear.h:5053
struct nk_vec2 last
Definition: nuklear.h:5057
float max
Definition: nuklear.h:5055
enum nk_chart_type type
Definition: nuklear.h:5052
float range
Definition: nuklear.h:5055
int index
Definition: nuklear.h:5058
float min
Definition: nuklear.h:5055
Definition: nuklear.h:5061
float x
Definition: nuklear.h:5063
float h
Definition: nuklear.h:5063
int slot
Definition: nuklear.h:5062
float y
Definition: nuklear.h:5063
struct nk_chart_slot slots[NK_CHART_MAX_SLOT]
Definition: nuklear.h:5064
float w
Definition: nuklear.h:5063
Definition: nuklear.h:4030
nk_plugin_copy copy
Definition: nuklear.h:4033
nk_handle userdata
Definition: nuklear.h:4031
nk_plugin_paste paste
Definition: nuklear.h:4032
Definition: nuklear.h:240
nk_byte a
Definition: nuklear.h:240
nk_byte g
Definition: nuklear.h:240
nk_byte r
Definition: nuklear.h:240
nk_byte b
Definition: nuklear.h:240
Definition: nuklear.h:241
float r
Definition: nuklear.h:241
float g
Definition: nuklear.h:241
float b
Definition: nuklear.h:241
float a
Definition: nuklear.h:241
Definition: nuklear.h:4279
short cy
Definition: nuklear.h:4281
unsigned short r
Definition: nuklear.h:4282
struct nk_command header
Definition: nuklear.h:4280
short cx
Definition: nuklear.h:4281
struct nk_color color
Definition: nuklear.h:4284
float a[2]
Definition: nuklear.h:4283
Definition: nuklear.h:4270
struct nk_command header
Definition: nuklear.h:4271
float a[2]
Definition: nuklear.h:4275
unsigned short r
Definition: nuklear.h:4273
unsigned short line_thickness
Definition: nuklear.h:4274
struct nk_color color
Definition: nuklear.h:4276
short cx
Definition: nuklear.h:4272
short cy
Definition: nuklear.h:4272
Definition: nuklear.h:4345
nk_size end
Definition: nuklear.h:4350
struct nk_buffer * base
Definition: nuklear.h:4346
nk_size last
Definition: nuklear.h:4350
struct nk_rect clip
Definition: nuklear.h:4347
int use_clipping
Definition: nuklear.h:4348
nk_size begin
Definition: nuklear.h:4350
nk_handle userdata
Definition: nuklear.h:4349
Definition: nuklear.h:4263
struct nk_color color
Definition: nuklear.h:4267
struct nk_command header
Definition: nuklear.h:4264
unsigned short h
Definition: nuklear.h:4266
short y
Definition: nuklear.h:4265
unsigned short w
Definition: nuklear.h:4266
short x
Definition: nuklear.h:4265
Definition: nuklear.h:4255
unsigned short w
Definition: nuklear.h:4259
unsigned short line_thickness
Definition: nuklear.h:4258
struct nk_command header
Definition: nuklear.h:4256
short x
Definition: nuklear.h:4257
unsigned short h
Definition: nuklear.h:4259
struct nk_color color
Definition: nuklear.h:4260
short y
Definition: nuklear.h:4257
Definition: nuklear.h:4202
struct nk_vec2i ctrl[2]
Definition: nuklear.h:4207
struct nk_command header
Definition: nuklear.h:4203
struct nk_color color
Definition: nuklear.h:4208
struct nk_vec2i end
Definition: nuklear.h:4206
struct nk_vec2i begin
Definition: nuklear.h:4205
unsigned short line_thickness
Definition: nuklear.h:4204
Definition: nuklear.h:4320
short y
Definition: nuklear.h:4322
unsigned short w
Definition: nuklear.h:4323
struct nk_command header
Definition: nuklear.h:4321
short x
Definition: nuklear.h:4322
nk_command_custom_callback callback
Definition: nuklear.h:4325
nk_handle callback_data
Definition: nuklear.h:4324
unsigned short h
Definition: nuklear.h:4323
Definition: nuklear.h:4310
struct nk_color col
Definition: nuklear.h:4315
unsigned short h
Definition: nuklear.h:4313
struct nk_command header
Definition: nuklear.h:4311
short y
Definition: nuklear.h:4312
unsigned short w
Definition: nuklear.h:4313
short x
Definition: nuklear.h:4312
struct nk_image img
Definition: nuklear.h:4314
Definition: nuklear.h:4194
unsigned short line_thickness
Definition: nuklear.h:4196
struct nk_command header
Definition: nuklear.h:4195
struct nk_vec2i begin
Definition: nuklear.h:4197
struct nk_vec2i end
Definition: nuklear.h:4198
struct nk_color color
Definition: nuklear.h:4199
Definition: nuklear.h:4295
struct nk_vec2i points[1]
Definition: nuklear.h:4299
unsigned short point_count
Definition: nuklear.h:4298
struct nk_color color
Definition: nuklear.h:4297
struct nk_command header
Definition: nuklear.h:4296
Definition: nuklear.h:4287
struct nk_command header
Definition: nuklear.h:4288
unsigned short line_thickness
Definition: nuklear.h:4290
unsigned short point_count
Definition: nuklear.h:4291
struct nk_color color
Definition: nuklear.h:4289
struct nk_vec2i points[1]
Definition: nuklear.h:4292
Definition: nuklear.h:4302
unsigned short line_thickness
Definition: nuklear.h:4305
struct nk_vec2i points[1]
Definition: nuklear.h:4307
struct nk_color color
Definition: nuklear.h:4304
struct nk_command header
Definition: nuklear.h:4303
unsigned short point_count
Definition: nuklear.h:4306
Definition: nuklear.h:4220
short x
Definition: nuklear.h:4223
struct nk_command header
Definition: nuklear.h:4221
short y
Definition: nuklear.h:4223
unsigned short w
Definition: nuklear.h:4224
unsigned short rounding
Definition: nuklear.h:4222
unsigned short h
Definition: nuklear.h:4224
struct nk_color color
Definition: nuklear.h:4225
Definition: nuklear.h:4228
struct nk_command header
Definition: nuklear.h:4229
struct nk_color top
Definition: nuklear.h:4233
struct nk_color left
Definition: nuklear.h:4232
struct nk_color right
Definition: nuklear.h:4235
short y
Definition: nuklear.h:4230
unsigned short h
Definition: nuklear.h:4231
struct nk_color bottom
Definition: nuklear.h:4234
short x
Definition: nuklear.h:4230
unsigned short w
Definition: nuklear.h:4231
Definition: nuklear.h:4211
short y
Definition: nuklear.h:4215
unsigned short h
Definition: nuklear.h:4216
struct nk_color color
Definition: nuklear.h:4217
unsigned short w
Definition: nuklear.h:4216
unsigned short rounding
Definition: nuklear.h:4213
unsigned short line_thickness
Definition: nuklear.h:4214
struct nk_command header
Definition: nuklear.h:4212
short x
Definition: nuklear.h:4215
Definition: nuklear.h:4188
short y
Definition: nuklear.h:4190
unsigned short h
Definition: nuklear.h:4191
unsigned short w
Definition: nuklear.h:4191
struct nk_command header
Definition: nuklear.h:4189
short x
Definition: nuklear.h:4190
Definition: nuklear.h:4328
char string[1]
Definition: nuklear.h:4337
struct nk_color background
Definition: nuklear.h:4331
const struct nk_user_font * font
Definition: nuklear.h:4330
struct nk_command header
Definition: nuklear.h:4329
int length
Definition: nuklear.h:4336
struct nk_color foreground
Definition: nuklear.h:4332
short x
Definition: nuklear.h:4333
float height
Definition: nuklear.h:4335
short y
Definition: nuklear.h:4333
unsigned short h
Definition: nuklear.h:4334
unsigned short w
Definition: nuklear.h:4334
Definition: nuklear.h:4247
struct nk_vec2i b
Definition: nuklear.h:4250
struct nk_vec2i c
Definition: nuklear.h:4251
struct nk_command header
Definition: nuklear.h:4248
struct nk_vec2i a
Definition: nuklear.h:4249
struct nk_color color
Definition: nuklear.h:4252
Definition: nuklear.h:4238
unsigned short line_thickness
Definition: nuklear.h:4240
struct nk_vec2i a
Definition: nuklear.h:4241
struct nk_vec2i b
Definition: nuklear.h:4242
struct nk_vec2i c
Definition: nuklear.h:4243
struct nk_color color
Definition: nuklear.h:4244
struct nk_command header
Definition: nuklear.h:4239
Definition: nuklear.h:4180
enum nk_command_type type
Definition: nuklear.h:4181
nk_size next
Definition: nuklear.h:4182
Definition: nuklear.h:5299
struct nk_config_stack_vec2 vectors
Definition: nuklear.h:5302
struct nk_config_stack_flags flags
Definition: nuklear.h:5303
struct nk_config_stack_style_item style_items
Definition: nuklear.h:5300
struct nk_config_stack_color colors
Definition: nuklear.h:5304
struct nk_config_stack_float floats
Definition: nuklear.h:5301
struct nk_config_stack_button_behavior button_behaviors
Definition: nuklear.h:5306
struct nk_config_stack_user_font fonts
Definition: nuklear.h:5305
Definition: nuklear.h:5352
int build
Definition: nuklear.h:5381
int use_pool
Definition: nuklear.h:5382
nk_flags last_widget_state
Definition: nuklear.h:5358
enum nk_button_behavior button_behavior
Definition: nuklear.h:5359
unsigned int count
Definition: nuklear.h:5389
struct nk_style style
Definition: nuklear.h:5355
float delta_time_seconds
Definition: nuklear.h:5361
struct nk_window * begin
Definition: nuklear.h:5384
unsigned int seq
Definition: nuklear.h:5390
struct nk_window * current
Definition: nuklear.h:5387
struct nk_buffer memory
Definition: nuklear.h:5356
struct nk_window * end
Definition: nuklear.h:5385
struct nk_clipboard clip
Definition: nuklear.h:5357
struct nk_pool pool
Definition: nuklear.h:5383
struct nk_configuration_stacks stacks
Definition: nuklear.h:5360
struct nk_page_element * freelist
Definition: nuklear.h:5388
struct nk_window * active
Definition: nuklear.h:5386
struct nk_input input
Definition: nuklear.h:5354
struct nk_text_edit text_edit
Definition: nuklear.h:5376
struct nk_command_buffer overlay
Definition: nuklear.h:5378
Definition: nuklear.h:937
enum nk_anti_aliasing shape_AA
Definition: nuklear.h:940
enum nk_anti_aliasing line_AA
Definition: nuklear.h:939
nk_size vertex_alignment
Definition: nuklear.h:947
nk_size vertex_size
Definition: nuklear.h:946
float global_alpha
Definition: nuklear.h:938
const struct nk_draw_vertex_layout_element * vertex_layout
Definition: nuklear.h:945
unsigned arc_segment_count
Definition: nuklear.h:942
unsigned circle_segment_count
Definition: nuklear.h:941
struct nk_draw_null_texture null
Definition: nuklear.h:944
unsigned curve_segment_count
Definition: nuklear.h:943
Definition: nuklear.h:249
struct nk_vec2 size offset
Definition: nuklear.h:249
struct nk_image img
Definition: nuklear.h:249
Definition: nuklear.h:933
nk_handle texture
Definition: nuklear.h:934
struct nk_vec2 uv
Definition: nuklear.h:935
Definition: nuklear.h:5165
unsigned int seq
Definition: nuklear.h:5167
int active
Definition: nuklear.h:5169
int sel_end
Definition: nuklear.h:5172
nk_hash name
Definition: nuklear.h:5166
int prev
Definition: nuklear.h:5169
unsigned char single_line
Definition: nuklear.h:5175
int cursor
Definition: nuklear.h:5170
unsigned int old
Definition: nuklear.h:5168
unsigned char mode
Definition: nuklear.h:5174
int sel_start
Definition: nuklear.h:5171
struct nk_scroll scrollbar
Definition: nuklear.h:5173
Definition: nuklear.h:248
unsigned short region[4]
Definition: nuklear.h:248
unsigned short h
Definition: nuklear.h:248
unsigned short w
Definition: nuklear.h:248
nk_handle handle
Definition: nuklear.h:248
Definition: nuklear.h:4398
unsigned int clicked
Definition: nuklear.h:4400
int down
Definition: nuklear.h:4399
Definition: nuklear.h:4402
int text_len
Definition: nuklear.h:4405
struct nk_key keys[NK_KEY_MAX]
Definition: nuklear.h:4403
char text[NK_INPUT_MAX]
Definition: nuklear.h:4404
Definition: nuklear.h:2808
nk_uint scroll_value
Definition: nuklear.h:2815
int end
Definition: nuklear.h:2810
int count
Definition: nuklear.h:2810
int begin
Definition: nuklear.h:2810
nk_uint * scroll_pointer
Definition: nuklear.h:2814
int total_height
Definition: nuklear.h:2812
struct nk_context * ctx
Definition: nuklear.h:2813
Definition: nuklear.h:3875
nk_size needed
Definition: nuklear.h:3880
nk_size allocated
Definition: nuklear.h:3879
void * memory
Definition: nuklear.h:3876
unsigned int type
Definition: nuklear.h:3877
nk_size calls
Definition: nuklear.h:3881
nk_size size
Definition: nuklear.h:3878
Definition: nuklear.h:3900
nk_size size
Definition: nuklear.h:3900
void * ptr
Definition: nuklear.h:3900
Definition: nuklear.h:4387
struct nk_vec2 pos
Definition: nuklear.h:4389
struct nk_mouse_button buttons[NK_BUTTON_MAX]
Definition: nuklear.h:4388
unsigned char ungrab
Definition: nuklear.h:4395
unsigned char grabbed
Definition: nuklear.h:4394
struct nk_vec2 scroll_delta
Definition: nuklear.h:4392
unsigned char grab
Definition: nuklear.h:4393
struct nk_vec2 delta
Definition: nuklear.h:4391
struct nk_vec2 prev
Definition: nuklear.h:4390
Definition: nuklear.h:5329
union nk_page_data data
Definition: nuklear.h:5330
struct nk_page_element * prev
Definition: nuklear.h:5332
struct nk_page_element * next
Definition: nuklear.h:5331
Definition: nuklear.h:5335
struct nk_page * next
Definition: nuklear.h:5337
struct nk_page_element win[1]
Definition: nuklear.h:5338
unsigned int size
Definition: nuklear.h:5336
Definition: nuklear.h:5108
float border
Definition: nuklear.h:5117
enum nk_panel_type type
Definition: nuklear.h:5109
nk_uint * offset_x
Definition: nuklear.h:5112
struct nk_menu_state menu
Definition: nuklear.h:5120
float at_y
Definition: nuklear.h:5114
struct nk_chart chart
Definition: nuklear.h:5122
nk_flags flags
Definition: nuklear.h:5110
struct nk_rect clip
Definition: nuklear.h:5119
nk_uint * offset_y
Definition: nuklear.h:5113
float at_x
Definition: nuklear.h:5114
struct nk_row_layout row
Definition: nuklear.h:5121
unsigned int has_scrolling
Definition: nuklear.h:5118
float footer_height
Definition: nuklear.h:5115
struct nk_rect bounds
Definition: nuklear.h:5111
float max_x
Definition: nuklear.h:5114
struct nk_command_buffer * buffer
Definition: nuklear.h:5123
struct nk_panel * parent
Definition: nuklear.h:5124
float header_height
Definition: nuklear.h:5116
Definition: nuklear.h:5341
struct nk_allocator alloc
Definition: nuklear.h:5342
unsigned int page_count
Definition: nuklear.h:5344
nk_size size
Definition: nuklear.h:5348
struct nk_page_element * freelist
Definition: nuklear.h:5346
nk_size cap
Definition: nuklear.h:5349
unsigned capacity
Definition: nuklear.h:5347
enum nk_allocation_type type
Definition: nuklear.h:5343
struct nk_page * pages
Definition: nuklear.h:5345
Definition: nuklear.h:5178
unsigned int seq
Definition: nuklear.h:5186
int cursor
Definition: nuklear.h:5182
unsigned int old
Definition: nuklear.h:5187
int select_end
Definition: nuklear.h:5184
int select_start
Definition: nuklear.h:5183
nk_hash name
Definition: nuklear.h:5185
int active
Definition: nuklear.h:5179
int length
Definition: nuklear.h:5181
char buffer[NK_MAX_NUMBER_BUFFER]
Definition: nuklear.h:5180
int prev
Definition: nuklear.h:5179
int state
Definition: nuklear.h:5188
Definition: nuklear.h:244
float h
Definition: nuklear.h:244
float x
Definition: nuklear.h:244
float y
Definition: nuklear.h:244
float w
Definition: nuklear.h:244
Definition: nuklear.h:245
short h
Definition: nuklear.h:245
short w
Definition: nuklear.h:245
short y
Definition: nuklear.h:245
short x
Definition: nuklear.h:245
Definition: nuklear.h:5079
float height
Definition: nuklear.h:5082
float filled
Definition: nuklear.h:5089
int columns
Definition: nuklear.h:5084
int index
Definition: nuklear.h:5081
enum nk_panel_row_layout_type type
Definition: nuklear.h:5080
float min_height
Definition: nuklear.h:5083
int tree_depth
Definition: nuklear.h:5091
float item_height
Definition: nuklear.h:5087
float item_width
Definition: nuklear.h:5086
struct nk_rect item
Definition: nuklear.h:5090
float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS]
Definition: nuklear.h:5092
const float * ratio
Definition: nuklear.h:5085
float item_offset
Definition: nuklear.h:5088
Definition: nuklear.h:3947
int len
Definition: nuklear.h:3949
struct nk_buffer buffer
Definition: nuklear.h:3948
Definition: nuklear.h:4863
float rounding
Definition: nuklear.h:4872
struct nk_color border_color
Definition: nuklear.h:4866
struct nk_style_item background
Definition: nuklear.h:4865
float border
Definition: nuklear.h:4871
struct nk_vec2 padding
Definition: nuklear.h:4873
struct nk_color selected_color
Definition: nuklear.h:4867
struct nk_color color
Definition: nuklear.h:4868
Definition: nuklear.h:4876
struct nk_color label_active
Definition: nuklear.h:4886
struct nk_vec2 content_padding
Definition: nuklear.h:4902
struct nk_color label_normal
Definition: nuklear.h:4884
struct nk_style_item normal
Definition: nuklear.h:4878
struct nk_color border_color
Definition: nuklear.h:4881
struct nk_style_button button
Definition: nuklear.h:4894
enum nk_symbol_type sym_active
Definition: nuklear.h:4897
float border
Definition: nuklear.h:4900
struct nk_style_item hover
Definition: nuklear.h:4879
enum nk_symbol_type sym_hover
Definition: nuklear.h:4896
struct nk_vec2 spacing
Definition: nuklear.h:4904
struct nk_color symbol_active
Definition: nuklear.h:4891
struct nk_style_item active
Definition: nuklear.h:4880
enum nk_symbol_type sym_normal
Definition: nuklear.h:4895
struct nk_color label_hover
Definition: nuklear.h:4885
float rounding
Definition: nuklear.h:4901
struct nk_vec2 button_padding
Definition: nuklear.h:4903
struct nk_color symbol_normal
Definition: nuklear.h:4889
struct nk_color symbol_hover
Definition: nuklear.h:4890
Definition: nuklear.h:4798
struct nk_style_item active
Definition: nuklear.h:4802
struct nk_color selected_normal
Definition: nuklear.h:4818
struct nk_color cursor_normal
Definition: nuklear.h:4807
struct nk_color selected_text_hover
Definition: nuklear.h:4821
struct nk_style_scrollbar scrollbar
Definition: nuklear.h:4804
float border
Definition: nuklear.h:4824
float cursor_size
Definition: nuklear.h:4826
struct nk_color text_hover
Definition: nuklear.h:4814
struct nk_color border_color
Definition: nuklear.h:4803
struct nk_vec2 padding
Definition: nuklear.h:4828
struct nk_color cursor_text_normal
Definition: nuklear.h:4809
float rounding
Definition: nuklear.h:4825
struct nk_vec2 scrollbar_size
Definition: nuklear.h:4827
struct nk_color selected_hover
Definition: nuklear.h:4819
struct nk_color selected_text_normal
Definition: nuklear.h:4820
struct nk_color cursor_hover
Definition: nuklear.h:4808
struct nk_color text_active
Definition: nuklear.h:4815
struct nk_color text_normal
Definition: nuklear.h:4813
struct nk_style_item normal
Definition: nuklear.h:4800
float row_padding
Definition: nuklear.h:4829
struct nk_color cursor_text_hover
Definition: nuklear.h:4810
struct nk_style_item hover
Definition: nuklear.h:4801
Definition: nuklear.h:4598
enum nk_style_item_type type
Definition: nuklear.h:4599
union nk_style_item_data data
Definition: nuklear.h:4600
Definition: nuklear.h:4739
float rounding
Definition: nuklear.h:4753
struct nk_style_item normal
Definition: nuklear.h:4741
struct nk_color cursor_border_color
Definition: nuklear.h:4750
struct nk_color border_color
Definition: nuklear.h:4744
struct nk_style_item cursor_hover
Definition: nuklear.h:4748
float cursor_border
Definition: nuklear.h:4755
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4762
struct nk_style_item cursor_normal
Definition: nuklear.h:4747
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4761
struct nk_style_item cursor_active
Definition: nuklear.h:4749
struct nk_vec2 padding
Definition: nuklear.h:4757
float cursor_rounding
Definition: nuklear.h:4756
struct nk_style_item active
Definition: nuklear.h:4743
struct nk_style_item hover
Definition: nuklear.h:4742
float border
Definition: nuklear.h:4754
nk_handle userdata
Definition: nuklear.h:4760
Definition: nuklear.h:4832
enum nk_symbol_type sym_left
Definition: nuklear.h:4845
struct nk_style_button dec_button
Definition: nuklear.h:4855
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4859
nk_handle userdata
Definition: nuklear.h:4858
struct nk_style_item active
Definition: nuklear.h:4836
struct nk_style_edit edit
Definition: nuklear.h:4853
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4860
enum nk_symbol_type sym_right
Definition: nuklear.h:4846
struct nk_color label_hover
Definition: nuklear.h:4841
struct nk_color border_color
Definition: nuklear.h:4837
struct nk_color label_normal
Definition: nuklear.h:4840
float rounding
Definition: nuklear.h:4850
struct nk_style_item normal
Definition: nuklear.h:4834
struct nk_color label_active
Definition: nuklear.h:4842
float border
Definition: nuklear.h:4849
struct nk_vec2 padding
Definition: nuklear.h:4851
struct nk_style_button inc_button
Definition: nuklear.h:4854
struct nk_style_item hover
Definition: nuklear.h:4835
Definition: nuklear.h:4665
struct nk_color text_hover
Definition: nuklear.h:4678
float rounding
Definition: nuklear.h:4689
struct nk_vec2 padding
Definition: nuklear.h:4690
struct nk_style_item hover
Definition: nuklear.h:4668
struct nk_style_item hover_active
Definition: nuklear.h:4673
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4696
struct nk_color text_hover_active
Definition: nuklear.h:4683
struct nk_color text_normal
Definition: nuklear.h:4677
struct nk_vec2 image_padding
Definition: nuklear.h:4692
struct nk_vec2 touch_padding
Definition: nuklear.h:4691
struct nk_style_item normal_active
Definition: nuklear.h:4672
nk_handle userdata
Definition: nuklear.h:4695
struct nk_style_item normal
Definition: nuklear.h:4667
struct nk_color text_normal_active
Definition: nuklear.h:4682
nk_flags text_alignment
Definition: nuklear.h:4686
struct nk_color text_pressed
Definition: nuklear.h:4679
struct nk_style_item pressed
Definition: nuklear.h:4669
struct nk_color text_pressed_active
Definition: nuklear.h:4684
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4697
struct nk_style_item pressed_active
Definition: nuklear.h:4674
struct nk_color text_background
Definition: nuklear.h:4685
Definition: nuklear.h:4700
int show_buttons
Definition: nuklear.h:4727
struct nk_style_item cursor_active
Definition: nuklear.h:4716
struct nk_color bar_normal
Definition: nuklear.h:4708
struct nk_style_item cursor_normal
Definition: nuklear.h:4714
struct nk_vec2 spacing
Definition: nuklear.h:4723
struct nk_color border_color
Definition: nuklear.h:4705
struct nk_style_button dec_button
Definition: nuklear.h:4729
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4735
struct nk_style_item normal
Definition: nuklear.h:4702
float bar_height
Definition: nuklear.h:4721
struct nk_color bar_active
Definition: nuklear.h:4710
enum nk_symbol_type dec_symbol
Definition: nuklear.h:4731
struct nk_color bar_hover
Definition: nuklear.h:4709
nk_handle userdata
Definition: nuklear.h:4734
struct nk_style_button inc_button
Definition: nuklear.h:4728
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4736
enum nk_symbol_type inc_symbol
Definition: nuklear.h:4730
struct nk_vec2 padding
Definition: nuklear.h:4722
float rounding
Definition: nuklear.h:4720
struct nk_style_item hover
Definition: nuklear.h:4703
struct nk_style_item active
Definition: nuklear.h:4704
struct nk_color bar_filled
Definition: nuklear.h:4711
struct nk_style_item cursor_hover
Definition: nuklear.h:4715
struct nk_vec2 cursor_size
Definition: nuklear.h:4724
float border
Definition: nuklear.h:4719
Definition: nuklear.h:4907
struct nk_style_button node_maximize_button
Definition: nuklear.h:4916
struct nk_style_button tab_minimize_button
Definition: nuklear.h:4915
struct nk_style_button tab_maximize_button
Definition: nuklear.h:4914
enum nk_symbol_type sym_minimize
Definition: nuklear.h:4918
float indent
Definition: nuklear.h:4924
enum nk_symbol_type sym_maximize
Definition: nuklear.h:4919
float border
Definition: nuklear.h:4922
struct nk_style_item background
Definition: nuklear.h:4909
struct nk_style_button node_minimize_button
Definition: nuklear.h:4917
float rounding
Definition: nuklear.h:4923
struct nk_vec2 spacing
Definition: nuklear.h:4926
struct nk_color text
Definition: nuklear.h:4911
struct nk_color border_color
Definition: nuklear.h:4910
struct nk_vec2 padding
Definition: nuklear.h:4925
Definition: nuklear.h:4603
struct nk_vec2 padding
Definition: nuklear.h:4605
struct nk_color color
Definition: nuklear.h:4604
Definition: nuklear.h:4635
struct nk_style_item cursor_hover
Definition: nuklear.h:4644
struct nk_vec2 padding
Definition: nuklear.h:4654
struct nk_style_item hover
Definition: nuklear.h:4638
struct nk_color text_normal
Definition: nuklear.h:4647
struct nk_color border_color
Definition: nuklear.h:4640
struct nk_style_item cursor_normal
Definition: nuklear.h:4643
struct nk_color text_active
Definition: nuklear.h:4649
struct nk_style_item normal
Definition: nuklear.h:4637
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4662
struct nk_style_item active
Definition: nuklear.h:4639
struct nk_vec2 touch_padding
Definition: nuklear.h:4655
nk_flags text_alignment
Definition: nuklear.h:4651
struct nk_color text_hover
Definition: nuklear.h:4648
float border
Definition: nuklear.h:4657
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:4661
nk_handle userdata
Definition: nuklear.h:4660
struct nk_color text_background
Definition: nuklear.h:4650
float spacing
Definition: nuklear.h:4656
Definition: nuklear.h:4958
float group_border
Definition: nuklear.h:4976
struct nk_style_item fixed_background
Definition: nuklear.h:4960
struct nk_style_item scaler
Definition: nuklear.h:4970
struct nk_color background
Definition: nuklear.h:4961
struct nk_vec2 menu_padding
Definition: nuklear.h:4991
struct nk_color popup_border_color
Definition: nuklear.h:4964
float menu_border
Definition: nuklear.h:4975
struct nk_vec2 scrollbar_size
Definition: nuklear.h:4983
struct nk_vec2 tooltip_padding
Definition: nuklear.h:4992
struct nk_color group_border_color
Definition: nuklear.h:4968
struct nk_vec2 padding
Definition: nuklear.h:4986
struct nk_color combo_border_color
Definition: nuklear.h:4965
struct nk_color border_color
Definition: nuklear.h:4963
float combo_border
Definition: nuklear.h:4973
float min_row_height_padding
Definition: nuklear.h:4979
struct nk_vec2 combo_padding
Definition: nuklear.h:4989
struct nk_vec2 group_padding
Definition: nuklear.h:4987
struct nk_vec2 popup_padding
Definition: nuklear.h:4988
struct nk_vec2 spacing
Definition: nuklear.h:4982
float tooltip_border
Definition: nuklear.h:4977
float rounding
Definition: nuklear.h:4981
struct nk_color contextual_border_color
Definition: nuklear.h:4966
struct nk_style_window_header header
Definition: nuklear.h:4959
float contextual_border
Definition: nuklear.h:4974
struct nk_color tooltip_border_color
Definition: nuklear.h:4969
struct nk_vec2 contextual_padding
Definition: nuklear.h:4990
float border
Definition: nuklear.h:4972
struct nk_color menu_border_color
Definition: nuklear.h:4967
struct nk_vec2 min_size
Definition: nuklear.h:4984
float popup_border
Definition: nuklear.h:4978
Definition: nuklear.h:4995
struct nk_style_scrollbar scrollv
Definition: nuklear.h:5015
struct nk_style_toggle option
Definition: nuklear.h:5006
struct nk_style_button contextual_button
Definition: nuklear.h:5004
struct nk_style_edit edit
Definition: nuklear.h:5012
struct nk_style_text text
Definition: nuklear.h:5002
struct nk_style_scrollbar scrollh
Definition: nuklear.h:5014
struct nk_style_button button
Definition: nuklear.h:5003
struct nk_style_tab tab
Definition: nuklear.h:5016
struct nk_style_chart chart
Definition: nuklear.h:5013
struct nk_style_property property
Definition: nuklear.h:5011
struct nk_style_selectable selectable
Definition: nuklear.h:5008
struct nk_style_progress progress
Definition: nuklear.h:5010
struct nk_cursor * cursor_last
Definition: nuklear.h:4999
int cursor_visible
Definition: nuklear.h:5000
const struct nk_user_font * font
Definition: nuklear.h:4996
const struct nk_cursor * cursors[NK_CURSOR_COUNT]
Definition: nuklear.h:4997
struct nk_style_window window
Definition: nuklear.h:5018
struct nk_style_slider slider
Definition: nuklear.h:5009
const struct nk_cursor * cursor_active
Definition: nuklear.h:4998
struct nk_style_combo combo
Definition: nuklear.h:5017
struct nk_style_button menu_button
Definition: nuklear.h:5005
struct nk_style_toggle checkbox
Definition: nuklear.h:5007
Definition: nuklear.h:5315
unsigned int size
Definition: nuklear.h:5317
struct nk_table * next
Definition: nuklear.h:5320
unsigned int seq
Definition: nuklear.h:5316
nk_hash keys[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:5318
nk_uint values[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:5319
struct nk_table * prev
Definition: nuklear.h:5320
Definition: nuklear.h:4063
struct nk_str string
Definition: nuklear.h:4065
int select_end
Definition: nuklear.h:4071
struct nk_vec2 scrollbar
Definition: nuklear.h:4067
unsigned char active
Definition: nuklear.h:4077
unsigned char has_preferred_x
Definition: nuklear.h:4075
int cursor
Definition: nuklear.h:4069
unsigned char initialized
Definition: nuklear.h:4074
unsigned char single_line
Definition: nuklear.h:4076
unsigned char mode
Definition: nuklear.h:4072
float preferred_x
Definition: nuklear.h:4079
unsigned char cursor_at_end_of_line
Definition: nuklear.h:4073
struct nk_clipboard clip
Definition: nuklear.h:4064
unsigned char padding1
Definition: nuklear.h:4078
nk_plugin_filter filter
Definition: nuklear.h:4066
struct nk_text_undo_state undo
Definition: nuklear.h:4080
int select_start
Definition: nuklear.h:4070
Definition: nuklear.h:4036
int where
Definition: nuklear.h:4037
short delete_length
Definition: nuklear.h:4039
short char_storage
Definition: nuklear.h:4040
short insert_length
Definition: nuklear.h:4038
Definition: nuklear.h:4043
nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT]
Definition: nuklear.h:4045
short undo_char_point
Definition: nuklear.h:4048
short redo_point
Definition: nuklear.h:4047
short undo_point
Definition: nuklear.h:4046
short redo_char_point
Definition: nuklear.h:4049
struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT]
Definition: nuklear.h:4044
Definition: nuklear.h:3697
nk_handle userdata
Definition: nuklear.h:3698
nk_text_width_f width
Definition: nuklear.h:3702
float height
Definition: nuklear.h:3700
Definition: nuklear.h:242
float x
Definition: nuklear.h:242
float y
Definition: nuklear.h:242
Definition: nuklear.h:243
short y
Definition: nuklear.h:243
short x
Definition: nuklear.h:243
Definition: nuklear.h:5191
unsigned int table_count
Definition: nuklear.h:5210
struct nk_rect bounds
Definition: nuklear.h:5197
struct nk_window * next
Definition: nuklear.h:5213
struct nk_window * prev
Definition: nuklear.h:5214
struct nk_table * tables
Definition: nuklear.h:5209
char name_string[NK_WINDOW_MAX_NAME]
Definition: nuklear.h:5194
struct nk_edit_state edit
Definition: nuklear.h:5206
struct nk_scroll scrollbar
Definition: nuklear.h:5198
struct nk_popup_state popup
Definition: nuklear.h:5205
struct nk_command_buffer buffer
Definition: nuklear.h:5199
nk_flags flags
Definition: nuklear.h:5195
struct nk_property_state property
Definition: nuklear.h:5204
unsigned int seq
Definition: nuklear.h:5192
struct nk_panel * layout
Definition: nuklear.h:5200
struct nk_window * parent
Definition: nuklear.h:5215
unsigned int scrolled
Definition: nuklear.h:5207
float scrollbar_hiding_timer
Definition: nuklear.h:5201
nk_hash name
Definition: nuklear.h:5193
Definition: nuklear.h:247
int id
Definition: nuklear.h:247
void * ptr
Definition: nuklear.h:247
Definition: nuklear.h:5323
struct nk_table tbl
Definition: nuklear.h:5324
struct nk_panel pan
Definition: nuklear.h:5325
struct nk_window win
Definition: nuklear.h:5326
Definition: nuklear.h:4593
struct nk_color color
Definition: nuklear.h:4595
struct nk_image image
Definition: nuklear.h:4594